15,550 Topics

Member Avatar for
Member Avatar for Erikmmp

Hi I'm pretty new to C (about a week experience) and I was wondering if C had anything like Python's random.choice() function. Basically it just selected a random element from what you gave it, a number from an array or a character from a string. If there is no function …

Member Avatar for Erikmmp
0
121
Member Avatar for java_girl

Hi. I recently read that using the name of an array without brackets was one method for accessing the <address> of the array's first element. E.g: [code=c] #include <stdio.h> int arr[5] = { 2, 4, 6, 8, 10 }; int main( void ) { printf( "The address of the '2' …

Member Avatar for Luckychap
0
225
Member Avatar for riahc3

Is there a good webpage that explains how to use rand() and srand() correctly? Overall I need to learn how to generate a number between 0 and 3.

Member Avatar for Narue
0
216
Member Avatar for ahspats

i have to write a program that deletes special characters from a phone number. For Example: (0049)5599/85675-344 0049559985675344 i have started to program it, but it doesn't seem to function. here's my code: [CODE] #include <stdio.h> void affe(char nummer[]){ int n , i, z; n = strlen(nummer) - 1; for …

Member Avatar for ahspats
0
122
Member Avatar for serkan sendur
Member Avatar for serkan sendur
0
69
Member Avatar for Church

i'm trying to put a function call inside of a function call: [CODE]switch_statement(menu());[/CODE] switch_statement is a function call and so is menu. I want what menu is returning to go into switch_statement but i kinda don't want to bother making a new variable just for this task.. So is it …

0
90
Member Avatar for Creator07

Hello, I'm still a C beginner. I am trying to make a simple code for searching a string in a doc file. I want to search for a name in the "Employee Database", and display the employee data no,name,desgnation,reg no.,Projects worked. The template in the file is as follows: [CODE]Employee …

Member Avatar for devnar
0
108
Member Avatar for LightSystem

Hi. Im working on a project with a relative size and Ive run into a deadlock, I need some advice in how to proceed. I have a server that creates multiple threads to handle its clients, but each thread must serve a client multiple times, here is the thread handling …

Member Avatar for LightSystem
0
82
Member Avatar for latour1972

can someone help me for this cuz I dont know what to do [code=c] #include<stdio.h> #include<math.h> /**RLC Circuit**/ void main() { float v, r, l, c, f, i; long double Xc, Xl, Z, Vr, Vc, Vl; const double pi=3.1415926535; printf("Enter v="); scanf("%d",&v); printf("Enter r="); scanf("%d",&r); printf("Enter l="); scanf("%d",&l); printf("Enter c="); …

Member Avatar for Creator07
0
2K
Member Avatar for IrishUpstart

So I got this question where we are given a data (txt) file. We need to read it into an array, then report the first, fifth, and last entries of that file. Here is the code that I have thus far. It's reading the first, but the other two are …

Member Avatar for devnar
0
90
Member Avatar for atman

hello., im trying to create a validation block that checks if the number is multiple of 5. im new at c, could anyone give me a tip? thanx a lot! cheers!

Member Avatar for grumpier
0
87
Member Avatar for JCasso

Hi, I am programming a pos terminal by using C Programming language. I cannot use strtod() or atof (since it just calls strtod in it). Any advices on converting string to double without using these functions? Thanks in advance.

Member Avatar for ArkM
0
1K
Member Avatar for OutOfReach

Hey all, I am a C beginner. My problem with my code is that I get a segfault. Here's my code [CODE=C] #include <stdio.h> struct studentInfo { int totalClasses; float GPA; char studentName[41]; }; main() { int numOfStudents, i; printf("How many students would you like to take account of? "); …

Member Avatar for OutOfReach
0
118
Member Avatar for aamresh1

Can anybody please let me know the command to link two C files in Linux platform during compilation. Thanks, Amresh

Member Avatar for Salem
0
51
Member Avatar for LightSystem

Hello, I need some urgent help, I have a program that communicates with another program. Its basically a Q&A, where one side introduces a question and the other answers it. And yes this is a school work, and it needs to be delivered soon. Im posting here because Im quite …

Member Avatar for dreaddoC
0
88
Member Avatar for aamresh1

We tried compiling a code - multiply1.c in the Linux environment by giving the command gcc multiply1.c (we have renamed it) but its throwing errors like :- In function "main": undefined reference to '_gmpz_init_set_str' We are getting 6 to 7 this type of errors. Can you please let us know …

Member Avatar for aamresh1
0
165
Member Avatar for slimjimmer

Hi I'm trying to implement malloc into the following file but I am having some difficulty grasping the concept. My code: [code=c] #include <stdio.h> #include <stdlib.h> #include <string.h> #define HALF_PI 1.570639 #define EXPECTED_ARGS 2 #define LOWER_LIMIT 0 float Integrate (float upper_limit, float x[2][10000], float fx[2][10000]); int main (int argc, char* …

Member Avatar for slimjimmer
0
140
Member Avatar for flarn2006

I want to know how to read the status of my laptop lid in a Win32 C program. I don't want to use any libraries, not even MFC or .NET. Thanks in advance?

0
44
Member Avatar for LightSystem

Im trying to understand why a simple function I wrote doesnt work as it should, its probably some simple noob mistake, but its really making no sense. Here it is: [CODE=C] void justapoe(char seq[], int pos){ char c; int i; printf("Insert: "); scanf("%c", &c); seq[pos]=c; printf("Seq: "); for(i=10;i<50;i++){ printf("%c", seq[i]); …

Member Avatar for jephthah
0
89
Member Avatar for dusse

Hello guys, How can I read and write in the same file? I want to open a file that exists and write something in the end of each line of the file.. Ex: My_file: a b c d e f g h i I want to alter to: a b …

Member Avatar for Salem
0
86
Member Avatar for atman

Hey guys! Could anyone enlighten me how to draw a graphic window in c? which classes to use and maybe a basic example would be greatly appreciated. cheers!! im using XCode and i assume it doesnt have all the libs like Borland, or Visual studio... cheers!

Member Avatar for Ancient Dragon
0
61
Member Avatar for patkhor

Hi, I found this code for shuffle one-dimensional int array somewhere: [CODE]void shuffle(int *array, size_t n) { if (n > 1) { size_t i; for (i = 0; i < n - 1; i++) { size_t j = i + rand() / (RAND_MAX / (n - i) + 1); int …

Member Avatar for Salem
0
112
Member Avatar for AcidG3rm5

I have the following in a text file How old are you?:I am 1 year old. Basically, the ":" is the delimiter. "How old are you?" is the question and "I am 1 year old" is what i will reply when i get the question . There is basically 2 …

Member Avatar for Salem
0
115
Member Avatar for tonybowry

Hi all I've only been learning C for 6 weeks and have a project to convert arabic numbers to roman numerals. Part of the prgram must do this in batch mode. i.e. read integers from .txt file, convert and write numerals back to .txt file. It seems to be working …

Member Avatar for tonybowry
0
71
Member Avatar for atman

hello., in a few examples i noticed that pointers are declared in functions parameter list. ex [CODE] #include <stdio.h> void SwapEm (char *p_grade1, char *p_grade2); int main () { char grade1= 'D', grade2 = 'A'; printf ("At the beginning grade1 is %c and grade2 is %c\n", grade1, grade2); SwapEm (&grade1, …

Member Avatar for devnar
0
225
Member Avatar for riahc3

Hey I have this code: [CODE] void menu() { char opt do { system ("cls"); printf ("1 - Option 1"); printf ("2 - Option 2"); printf ("3 - Option 3"); [B]scanf ("%c",&opt);[/B] [B]}while ((opt!="1") && (opt!="2") && (opt!="3"));[/B] [/CODE] The lines in bold are the ones Im not sure about. …

Member Avatar for riahc3
0
146
Member Avatar for patkhor

Hi, I'm using fgets() to read lines of text file and display them. The fgets() is in an infinite loop. The problem occurs when I remove lines from text file while program is running. The lines count is correct, but the program display the old content of the file up …

Member Avatar for patkhor
0
98
Member Avatar for msundastud

ok, once again, I'm back...after this program I don't plan to write anymore...here's the task... Program # 1: Write a program that can decrypt the following string Ukjv!lt#xkz#DVT#sxmht1 Each character must be decrypted by applying the decryption algorithm to its ASCII value. The decryption algorithm is: • if array index …

Member Avatar for devnar
0
115
Member Avatar for dampecram

Hello, the program I have creates a database and lets you update/add/delete any information you want about hardware items. My problem is.. after I exit the program, all the data is lost in the binary file. I need to keep a database in a binary file and update it everytime …

Member Avatar for Ancient Dragon
0
99
Member Avatar for atman

hello., ny1 knows what is the data type for displaying hex numbers? i know that specifier is %x, but dont know what data type it is ex: 0xBCD thanx!

Member Avatar for devnar
0
85

The End.