Hi I am a new drain on the community ready to annoy the real programers.
I am wondering how to read a text file and then afterwards print it out. I am a bit lost, please be gentle with me.
Hi I am a new drain on the community ready to annoy the real programers.
I am wondering how to read a text file and then afterwards print it out. I am a bit lost, please be gentle with me.
Well... give it your best shot then, when you get stuck, post what you've got and we'll see what we can do...
There are several ways - word by word, char by char, line by line, etc.
Best if you started out with some tutorials, and worked your way up, on general C programming. Lots of C tutorials, but maybe start with this one:
Cprogramming.com: How to Get Started with C++
and Welcome to the forum, Roisis!
Code:#include <stdio.h> int main (int argc, const char * argv[]) { FILE *f; char s[1000]; f=fopen("/Users/rolsis/Desktop/mytext.txt", "r"); if(!f) return 1; while (fgets(s,1000,f)!=NULL) { printf("%s", s); } fclose(f); return 0; }
And you needed our help.... because?