Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 I need help with file handling???
Index -> Programming, C++ -> C++ Help
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
wtd




PostPosted: Mon Jun 12, 2006 4:26 pm   Post subject: (No subject)

Yeah, and I'm not trying to sound harsh. but it really does help to get an understanding of the basic concepts before trying anything that makes use of those concepts.

For instance, do you understand what those #include lines are doing?

I ask because you have some that serve no purpose in your program.
Sponsor
Sponsor
Sponsor
sponsor
programming.noob




PostPosted: Mon Jun 12, 2006 5:28 pm   Post subject: (No subject)

yes i think they are libraries.. pre preocessor directives
programming.noob




PostPosted: Mon Jun 12, 2006 5:29 pm   Post subject: (No subject)

the #include lines dont seem to be the obstacle for the compiler when i try to run it their is something it doesnt like about the conditions.

int read ()
{
char file [35];
FILE * pFile;
pFile = fopen ("bankdatabase.txt","r");
if (pFile!=NULL)
int a;
a=pFile;
puts ("bankdatabase.txt",pFile);
printf ("%d",a)
else
printf ("File read correctly but not displayed");

i thought i did it right. Can you please tell me the logic i need to follow to fix this.
programming.noob




PostPosted: Mon Jun 12, 2006 5:31 pm   Post subject: (No subject)

what i sent you is a portion fo the program it is only the file read and output to the screen part the other 75% of the program is done its this i cant get.
programming.noob




PostPosted: Tue Jun 13, 2006 12:03 pm   Post subject: (No subject)

how would i use strcmp...string compare to compare two strings. One which i get from the user and the second to check the input from the user in the file. How would i do this using C code.
wtd




PostPosted: Tue Jun 13, 2006 12:33 pm   Post subject: (No subject)

http://www.cplusplus.com/ref/cstring/strcmp.html

It's the first hit whe you Google "c strcmp". Rolling Eyes
programming.noob




PostPosted: Tue Jun 13, 2006 4:12 pm   Post subject: (No subject)

what can i do to ensure that the data from the file is read according to what the user enters. For e.g. if the user enters barry john then the line with details of barry john should be seen in the run window.
wtd




PostPosted: Tue Jun 13, 2006 4:39 pm   Post subject: (No subject)

You read the name the user is looking for.

As you read each line in the file, you check to see if it starts with that name. If it does, you print that line. Otherwise you go to the next line.

If no lines satisyf this criteria, then obviously the user needs to try a different name.
Sponsor
Sponsor
Sponsor
sponsor
programming.noob




PostPosted: Tue Jun 13, 2006 6:35 pm   Post subject: (No subject)

How can i delete records from a file if i wanted to suppose delete a specific line with the name entered by the user. if user enters john barry then delete john barry information from the file.
Martin




PostPosted: Tue Jun 13, 2006 8:57 pm   Post subject: (No subject)

Slow down and take everything one step at a time, right from the beginning.

Learn about the structure of a basic C program. Learn what everything means. Learn how to use for loops and if statements and blocks within C. Learn the basics of how pointers and variables work and then move on to file input and such. Your problem right now is that you don't understand C's syntax - you're trying to run before you've learnt how to walk.
programming.noob




PostPosted: Wed Jun 14, 2006 7:42 am   Post subject: (No subject)

ok
programming.noob




PostPosted: Wed Jun 14, 2006 7:44 am   Post subject: (No subject)

it may seem like that but i do know the syntax a basic program flow.. i just cant think because i get nervous that its not going to work and have issues debugging.
Martin




PostPosted: Thu Jun 15, 2006 12:10 am   Post subject: (No subject)

Well, first off, what compiler are you using? I would recommend you download and install Cygwin (assuming that you are on Windows). With the installer, you should get GCC (which is the GNU Compiler Collection, which includes a C compiler).

And don't be scared to compile programs that you know won't work - it won't hurt your computer, and you'll gain a better understanding of the language by knowing both what works and what doesn't work.
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 28 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: