|
The statement, line [128], in your .cpp file is not a syntactically correct declaration. Just toss it. Further, sizeof line does not get you the size of the array; it gets you the size of a pointer to line.
If you want to use the array in several places, it has to be accessible in those places. This means you need to pass its location (where ever you decide to put it) around to where you need it.
Your treatment regarding the newline character is just a bunch of logical waste. Read the docs for fgets. If you get a newline, it will be the last character (find that with strlen). No point setting it to a newline if it's already there. You might want to get rid of it by dumping a '\0' over it. If you want to add one, you'll need to make the buffer one byte longer than the length you ask for.
|