Help With C I/o Code - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Help With C I/o Code (935 Views)
| Help With C I/o Code by Fayimora(op): 2:03pm On Jul 11, 2011 |
Hey guys can someone help me with this c code? It reads a fils and prints its contents on the screen. i wrote it last yr wen i was learning c and now i can't remember what happens where, Thanks /* Program to display the contents of a file on screen */ Thanks in advance |
| Re: Help With C I/o Code by Nobody: 5:35pm On Jul 11, 2011*. Modified: 2:44am On Apr 07, 2013 |
| Re: Help With C I/o Code by Ghenghis(m): 7:24pm On Jul 11, 2011 |
first rule of programming, "thou shalt debug thy own code"! /* Program to display the contents of a file on screen */ #include <stdio.h> int main(void) { //declare pointers file FILE *fopen(), *fp; int c; //open file for read access fp = fopen("data.txt","r" ;//read a character c = getc(fp) ; while (c != EOF)//while character is not end of file sentinel continue { putchar(c);//print character c = getc(fp); // read next character } fclose(fp); //close file return 0; } |
| Re: Help With C I/o Code by Fayimora(op): 7:33pm On Jul 11, 2011 |
@omo_to_dun. Explain. @ghenghis thanks. Already carped bombed it with debugging statements wen i ddnt get a quick reply. Thanks anyways |
| Re: Help With C I/o Code by Nobody: 8:27pm On Jul 11, 2011*. Modified: 2:44am On Apr 07, 2013 |
| Re: Help With C I/o Code by Fayimora(op): 8:29pm On Jul 11, 2011 |
Am revisiting c, A lil bit easy cause i do objective-c |
| Re: Help With C I/o Code by Nobody: 8:38pm On Jul 11, 2011*. Modified: 2:44am On Apr 07, 2013 |
| Re: Help With C I/o Code by Fayimora(op): 8:51pm On Jul 11, 2011 |
hhehhehe cool. Am looking for some video tutorials but cant find any. Its a lil bit as interesting as ma almighty perl :d |
| Re: Help With C I/o Code by Nobody: 8:59pm On Jul 11, 2011*. Modified: 2:44am On Apr 07, 2013 |
| Re: Help With C I/o Code by Fayimora(op): 10:47pm On Jul 11, 2011 |
omo_to_dun:Lolzz yeah perl is kinda clumsy even very ugly but trust me, i have gained a lot from it, Made some scripts that just makes ma life easy.One problem with perl is that its hard to learn but you only learn it once and you become a boss. Take for example, when i write code for someone(say a mini-software with 6 classes in Java). I don't have to go through each code to place the header licence, all i do is write a 4 line script to do the jon in less than a second. Perl is just the bomb. The only thing i still haven't gotten an answer to is "Perl and Ruby, which is better?". |
Google I/O 2015 • [google I/O] Google Introduces Native Client, Add C And C++ Code Web Apps • What Is The Relationship Between Processor And I/o Device • 2 • 3 • 4
I Need A Detailed And Expert Help In Explanation Of Classes And Objects In C++ • If You Have Passion For OOP Is Different To You Want To Learn Or Know OOP • Meet Joe Green, The Guy Who Walked Away From $17B Facebook Fortune
;