hello,
i am trying to paste into a variable the first line i get from a file with fgets. this is done in a loop so if the condition is true it continues and loads the next line from the file into the variable.
I cant understand how i can place the respective line in the variable mynames. could someone explain me please what i am doing wrong. thanks for your help as i am pretty new with c and i could easilly brake my keyboard right nowCode:char line[80]; char *mynames; long counter = -1L; FILE *names; if ((names = fopen (filename, "r")) == NULL) { perror ("fopen"); exit (1); } else { for counter = 0L; fgets(line, sizeof(line), names) != NULL; //line = myname; counter += strlen(line));![]()



LinkBack URL
About LinkBacks



