| | |
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 binarysearch centimeter changingto char character cm convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax database directory feet fflush fgets file floatingpointvalidation fork frequency function givemetehcodez global graphics gtkgcurlcompiling gtkwinlinux highest histogram homework i/o inches infiniteloop input interest intmain() iso keyboard kilometer km linked linkedlist linux linuxsegmentationfault list locate looping lowest match meter microsoft mqqueue mysql oddnumber odf open opendocumentformat openwebfoundation owf pattern pdf performance posix power probleminc program programming pyramidusingturboccodes read recv recvblocked repetition reversing scanf scheduling segmentationfault send single socketprograming socketprogramming stack standard string suggestions systemcall unix urboc user voidmain() wab whythiscodecausesegmentationfault win32api windows.h windowsapi






