| | |
can any body explain this program
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jun 2008
Posts: 21
Reputation:
Solved Threads: 0
Hi,
the concept of the program is enter a piece of text from the keyboard and place that piece of text into a file
But, after completing this program
when I open the text file there is no result at all
what is the problem is it really write the contents to a new.txt file or not. If yes please explain briefly why my text file is not changin
else please give the solution
regards,
the concept of the program is enter a piece of text from the keyboard and place that piece of text into a file
c Syntax (Toggle Plain Text)
#include<stdio.h> #include<conio.h> #include<stdlib.h> #include<string.h> void main() { FILE *fp; char s[80]; fp=fopen("new.txt","w"); if(fp==NULL) { printf("unable to open file"); exit(1); } printf("enter new line of text:\n"); while(strlen(gets(s))>0) { fputs(s, fp); fputs("\n", fp); } fclose(fp); }
when I open the text file there is no result at all
what is the problem is it really write the contents to a new.txt file or not. If yes please explain briefly why my text file is not changin
else please give the solution
regards,
Last edited by Narue; Nov 25th, 2008 at 9:42 am. Reason: added code tags
This is your 14th post, and you still don't bother to use code tags. Also it was mentioned quite a lot of times in your previous thread that you should use
int main instead of void main . Read this article.
There's a very well explained article by Steve Summit about the incorrect usage of main's return type. It's in the link pasted above. Anyway, here's a direct link. It certainly helped me when I was trying to understand what all the noise about main's return type was... which wasn't very long back actually.
There's a very well explained article by Steve Summit about the incorrect usage of main's return type. It's in the link pasted above. Anyway, here's a direct link. It certainly helped me when I was trying to understand what all the noise about main's return type was... which wasn't very long back actually.
![]() |
Similar Threads
- Apache (Linux Servers and Apache)
- Fluid Mechanics program help (C)
- New to Perl, please explain the script (Perl)
- complex declarations & other doubts (C++)
- Program alone doesn't help. (C++)
- xp remote desktop across wan/lan (Windows NT / 2000 / XP)
- warms and proccess problems (Viruses, Spyware and other Nasties)
- I've got Trojan.Holax... is this bad? (Viruses, Spyware and other Nasties)
- not-a-virusadware (Viruses, Spyware and other Nasties)
- Interesting problem : please see this and reply (C)
Other Threads in the C Forum
- Previous Thread: Checking EOF while using fgets()... Confused.
- Next Thread: fscanf questions
Views: 423 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for C
adobe ansi api array arrays bash binarysearch centimeter char convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory drawing dynamic executable fflush file fork frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hardware highest homework i/o inches infiniteloop initialization interest km lazy linked linkedlist linux linuxsegmentationfault list locate logical_drives match matrix meter microsoft motherboard multi mysql open opendocumentformat opensource owf pattern pdf performance pointer pointers posix power problem probleminc program programming pyramidusingturboccodes read recursion recv repetition scanf scheduling segmentationfault send shape socketprograming spoonfeeding stack standard strchr string strings structures student suggestions system systemcall test testautomation unix user visualstudio voidmain() wab win32 win32api windows.h





