| | |
Help in Input output C files
![]() |
•
•
Join Date: Aug 2004
Posts: 4
Reputation:
Solved Threads: 0
Hi guys / girls i am new in this forum and i hope you could help me in this problem.
i programmed a link list which stores some information one of them is strings and i entered them using the function gets(); instead of scanf(); to enable the program to read the space character, and at the termination of the program i call a function to save the linked list to a file but the problem aarise when i return and open the file and load the link list from the file to Main Memmory this what happen:
suppose i entered the string "aaaa bbbb" note that there is a space..
when i close the program and then reexecute it and use the function
fscanf(); to read from a file it consider "aaaa" a string and "bbbb" another string it don't consider them as one string.
please help me.. :rolleyes: :rolleyes: :rolleyes:
i programmed a link list which stores some information one of them is strings and i entered them using the function gets(); instead of scanf(); to enable the program to read the space character, and at the termination of the program i call a function to save the linked list to a file but the problem aarise when i return and open the file and load the link list from the file to Main Memmory this what happen:
suppose i entered the string "aaaa bbbb" note that there is a space..
when i close the program and then reexecute it and use the function
fscanf(); to read from a file it consider "aaaa" a string and "bbbb" another string it don't consider them as one string.
please help me.. :rolleyes: :rolleyes: :rolleyes:
•
•
•
•
Originally Posted by wild_potatos
Hi guys / girls i am new in this forum and i hope you could help me in this problem.
i programmed a link list which stores some information one of them is strings and i entered them using the function gets(); instead of scanf(); to enable the program to read the space character, and at the termination of the program i call a function to save the linked list to a file but the problem aarise when i return and open the file and load the link list from the file to Main Memmory this what happen:
suppose i entered the string "aaaa bbbb" note that there is a space..
when i close the program and then reexecute it and use the function
fscanf(); to read from a file it consider "aaaa" a string and "bbbb" another string it don't consider them as one string.
please help me.. :rolleyes: :rolleyes: :rolleyes:
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Yea, better use fstreams they are much better and easier to use.Here's a link:
http://www.daniweb.com/techtalkforums/thread6542.html
Try posting some of your code too.We might be able to help you better then.
http://www.daniweb.com/techtalkforums/thread6542.html
Try posting some of your code too.We might be able to help you better then.
An example:
C Syntax (Toggle Plain Text)
#include <stdio.h> struct name { char first[16]; char last[32]; }; int main(void) { char line [ BUFSIZ ]; fputs("Name (First Last)? ", stdout); fflush(stdout); if ( fgets(line, sizeof line, stdin) ) { struct name myname; if ( sscanf(line, "%15s%31s", myname.first, myname.last) == 2 ) { printf("myname: first = \"%s\", last = \"%s\"\n", myname.first, myname.last); } } return 0; } /* my output Name (First Last)? Dave Sinkula myname: first = "Dave", last = "Sinkula" */
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Files are streams just like stdin and stdout. Surely you can open a file; and surely you could using fprintf instead of printf without much issue -- so what code can you post that does not behave as you'd like?
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
![]() |
Similar Threads
- Parse and mail log files (Perl)
- file stream. where do .dat files go? (C++)
- How to define in sql server the same parameter as input and output both (MS SQL)
- Getting all data from an input and output file (C++)
- Reading an input file as a class memeber function (C++)
- Make files (C)
- ProgramIntro(input,output) (Community Introductions)
Other Threads in the C Forum
- Previous Thread: variable function parameters functionname(int a, ...)
- Next Thread: circular link list
| Thread Tools | Search this Thread |
#include adobe ansi api array asterisks binarysearch changingto char character cm copyimagefile cprogramme creafecopyofanytypeoffileinc createcopyoffile csyntax database directory dynamic execv feet fgets file fork forloop frequency function getlasterror givemetehcodez global grade graphics gtkgcurlcompiling hacking hardware highest histogram i/o include incrementoperators infiniteloop input interest kernel keyboard kilometer license linked linkedlist linux linuxsegmentationfault list locate logical_drives looping loopinsideloop. lowest match matrix meter microsoft motherboard mqqueue mysql number odf opensource owf pattern pdf performance pointer posix probleminc process program programming radix recursion recv repetition research reversing scanf segmentationfault sequential shape socket socketprograming standard string systemcall threads turboc unix user voidmain() wab windows.h windowsapi






