beginner needs help with code
to read from data file to 2 dim array
display data to screen
open output file
display data to screen in reverse order
write data to output file in reverse order
beginner needs help with code
to read from data file to 2 dim array
display data to screen
open output file
display data to screen in reverse order
write data to output file in reverse order
We're not going to do your homework for you -- at least not from scratch. Attempt it and if it's still not working then post what you get (and use code tags). We'll help you fix your errors from there.
i'll show you what i have
#include <stdio.h>
#include <stdlib.h>
FILE * Fileptr;
struct Client //* defines the 2 dim array*//
{
char Lname[15]
char fname [15]
int count;
}Record[];
main()
{
int count;
for (count=0;count<5;count++)
}
client[count]=fill (client[count]); //* fill the array *//
}
while (fscanf(Fileptr, "%C, &Lname) != EOF));
{
fscanf(FilePtr, "%c, &Fname);
{
int count;
for (count=0;count<5;count++)
{
fread(&Client[count], sizeof(Record,, 1, FilePtr);//*read into*//
}
fclose(FilePtr);
return(0);
}
printf("First Name: "%c" Last Name: "%c , Fname, Lname);
}
fclose(FilePointer);
{
FilePtr = fopen ("output.dat","w");//*open output file*//
int count =0;
for (count=0; count <5; count++)
{
fwrite(&Record[count], sizeof(Client), 1, FilePtr);//*write *//
}
fclose(FilePtr);
{
FilePtr=fopen(output.dat", "r");
int count=4;
for(count=4;count=0;count--);
fread(&Record[count], sizeof(client, 1, FilePtr);
printf ("First name:" %c "Last Name" %c, Fname, Lname);
Last edited by ddavidson; 02-12-2003 at 07:22 AM.
>>(and use code tags)
Read this, and edit your post accordingly please.
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
the attached file needs some work
I am sure that there are some very good people out there who can fix this in minutes
Can someone show me the way
Much Thanks
Your code is very unstructured. IMHO it is very hard to read/understand.Code:if ((FilePtr = fopen("client.dat","r")) = NULL); it must be: if ((FilePtr = fopen("client.dat","r")) == NULL); for (count =4 ;count=0; count--) I guess you want: for (count =4 ;count>0; count--) // or >= 0
Do not include the function source code in main().
And the brackets are unbalanced ... but it is hard to tell where to remove/add brackets.
But you clearly forgot to put the function body of "int Open_File()" in brackets.