help please

Pages: 12
I've never used C and I've never used a main function where I didn't use
return 0

So why would you use

exit(-3)

is that some way of indicating a file failure?
Last edited on
(It opens and reads from a data file id’s and grade and name. The number of lines of input is unknown )
the number of line input unknown so the peogram asks for unlimited no maxmium i put the number 100 for the size i dont know how to do unlimited and i guess the doctor will take points for that ...

the course is called c++ and we use devc++ to work with ..
anyway there is 12 hour left for the sumbmission and i dont think i will complete it on time so thanks guys for your help
It was my way of signifying a failure to properly execute.

A return/exit code of anything other than '0' tells the OS that the program did not execute properly, and it is a way to 1) determine why it crashed and 2) inform the user that it did not operate properly.

My code that I just put there can read and print an arbitrary number of lines, as long as the lines has a long, followed by an integer, followed by a string. the "== 3" is making sure it captures all 3 pieces on the line. If it doesn't capture all 3, it should stop reading the file.

DevC++ is an IDE, not a language. The language for this program is very much C.
Last edited on
I'm most familiar with using vectors or lists.

If you're not able to use either of those, the only thing I can think of is calling a function that reallocates and increases the array size. I would write it out but I'm not too familiar with allocation in C... Perhaps C has a way of allocating one additional item at the end of the array.
Last edited on
for(i=0;fscanf(input,"%d %d %s ",&id[i],&grade[i],&name[i])!=EOF;i++){

}
printf("%s \n",&name[0]);


when i do it like that it prints the first letter of the first name and the first letter of second name and the last name but when i do it like that

for(i=0;fscanf(input,"%d %d %s ",&id[i],&grade[i],&name[i])!=EOF;i++){

printf("%s \n",&name[i]);
}

the name come as i put them in order

so whats wrong why the name different when i call it outside the loop but inside the loop it comes right
Topic archived. No new replies allowed.
Pages: 12