| | |
Problems of looping in saving to a text file
![]() |
•
•
Join Date: Oct 2004
Posts: 11
Reputation:
Solved Threads: 0
hi below is my save function that is used to placed data from the C program to a text file for future usage.
There was no problem for me to save the first employee and the second but when adding the 3rd employee data, this is what appears in the text file :
1121 sonia cooling Management Maid 1121 sonia cooling Management Maid
1331 mustapha jamal Management Office_Boy 1121 sonia cooling Management Maid
1121 sonia cooling Management Maid
1331 mustapha jamal Management Office_Boy
1111 cheng kahhin Administration Chief_Executive_Officer
Sonia is the 1st employee I add, mustapha second and cheng the third. My data are ID firstname secondname department post and it seems the 1st and second loops before going to the third pls help if the problem is in the save function if not its in the add_function but I want to make sure if its the save function
void save()
{
FILE *save;
int i = 0;
save=fopen("employeerecord.txt", "a+");
do
{
if(strcmp(record[i].ID, "")!=0)
{
if(i!=0)
fprintf(save, "\n");
fprintf(save, "%s %s %s %s %s ", record[i].ID, record[i].Name, record[i].Name2, record[i].Department[storage], record[i].Post[rank]);
}
else
{
break;
}
i++;
}while(i<500);
fclose(save);
}1121 sonia cooling Management Maid 1121 sonia cooling Management Maid
1331 mustapha jamal Management Office_Boy 1121 sonia cooling Management Maid
1121 sonia cooling Management Maid
1331 mustapha jamal Management Office_Boy
1111 cheng kahhin Administration Chief_Executive_Officer
Sonia is the 1st employee I add, mustapha second and cheng the third. My data are ID firstname secondname department post and it seems the 1st and second loops before going to the third pls help if the problem is in the save function if not its in the add_function but I want to make sure if its the save function
Last edited by alc6379; Oct 30th, 2004 at 3:26 pm.
![]() |
Similar Threads
- how do I send a text file to a printer connected to the client's computer (ASP.NET)
- text file to pdf using xsl/svg problems (XML, XSLT and XPATH)
- problems editing dataGrid and 'Tab' delimited text file (C#)
- Newbie: problems deleting lines from text file (large) (Python)
- turning userinput into a text file (C)
- Help with a 2D array from a text file (C++)
- write to text file using fprintf() (C)
- Having roblems using PHP to send info as text file (PHP)
Other Threads in the C Forum
- Previous Thread: pls heeeeeeeeelp its urgent.
- Next Thread: Need help with small beginner program, please.
| Thread Tools | Search this Thread |
* adobe ansi api array arrays binarysearch calculate centimeter char character cm convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory dynamic feet fflush file floatingpointvalidation fork forloop frequency getlasterror getlogicaldrivestrin givemetehcodez global graphics gtkgcurlcompiling gtkwinlinux hacking highest homework i/o inches incrementoperators intmain() iso km linked linkedlist linux linuxsegmentationfault list locate logical_drives loopinsideloop. lowest match matrix microsoft mqqueue mysql oddnumber odf open opendocumentformat openwebfoundation pattern pdf performance pointer posix power program programming pyramidusingturboccodes read recursion recv recvblocked repetition reversing scanf scheduling segmentationfault send shape single socketprograming socketprogramming stack standard strchr string suggestions test unix urboc user variable voidmain() whythiscodecausesegmentationfault win32api windows.h






