Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,152,293 members, 7,815,510 topics. Date: Thursday, 02 May 2024 at 01:43 PM

Help With C I/o Code - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Help With C I/o Code (832 Views)

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)

(1) (Reply) (Go Down)

Help With C I/o Code by Fayimora(m): 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 */
#include <stdio.h>
int main(void)
{
FILE *fopen(), *fp;
int c;
fp = fopen("data.txt","r"wink;
c = getc(fp) ;
while (c != EOF)
{
putchar(c);
c = getc(fp);
}
fclose(fp);
return 0;
}

Thanks in advance
Re: Help With C I/o Code by Nobody: 5:35pm On Jul 11, 2011
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"wink;
//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(m): 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
Re: Help With C I/o Code by Fayimora(m): 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
Re: Help With C I/o Code by Fayimora(m): 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
Re: Help With C I/o Code by Fayimora(m): 10:47pm On Jul 11, 2011
omo_to_dun:

My brother, I do not f*ck with Perl; although that language can do anything you can imagine, it is too clumsy for me. The new Perl 6 is also adding functional language constructs to its already diverse repertoire. But when it comes to string processing, I hear Perl is king.
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?".

(1) (Reply)

Advice On Aplication Of SPSS / How To Setup Wifi On Nokia / How Too Make A Link Carry Out A Php Command

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 12
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.