![]() |
| ||
| read text file Hi all, I'd posted this problem previously but in the wrong place..:)..Hopefully, I can get the answer from this thread. I'm a newbie in C..Right now, I have to write a code to read a text file and then insert all the info inside that text file into database. Should anyone have a simple sample of it, maybe you can share with me in order for me to learn on how to do it. Thanks in advance |
| ||
| Re: read text file Quote:
// reading a text file I don't really get what you mean by sending it to a database, but this is the file-reading part Greetz, Eddy EDIT: Oh wait, you sayd "C", did you mean C or C++? If it's C above code probably won't work. If you're really doing C then I suggest you switch to C++ anyway ;) |
| ||
| Re: read text file Hi Eddy, Yerp, I need to write that code in C...n what I meant by sending it to database is that, I have 1 text file to be read, n after that, this program need to insert all the read data from that file into database. Actually, I've got that text file from other people and I need to insert that data into database so that, I can use it for my program.. Thanks |
| ||
| Re: read text file I still don't really get what you mean with the database. Is it an SQL database you need to put it to (or another type of database)? Or do you just mean an array(table) inside your own program? Greetz, Eddy |
| ||
| Re: read text file Hi Eddy, Actually, I want to read the file and then extract the content of the file to be inserted into the database (MySQL database). I had created a table in MySQL so that, when this C program run, it can read as well as inserting the content to that table created. Hope you can get what I mean..:) Thanks a lot |
| ||
| Re: read text file |
| ||
| Re: read text file |
| ||
| Re: read text file Hi all, Basically, I have done my code and it already successfully read the text file n insert the content into the database. But the problem is..i dunt know how to write a code so that, this program can read other files at the same time.Meaning that, I dunt want the filename to be hard coded because I'll receive 4 files to be read every hour. Below is the code: #include <stdio.h> Thanks |
| ||
| Re: read text file change readLogFile() so that you can pass the filename into it. readLogFile( const char* filename) then you can call readLogFile for any file you want. readLogFile("file1.txt"); |
| ||
| Re: read text file Hi WolfPack, Refer to your given code, it's work but I still need to hardcode the filename. I want it to automatically read all the files received because I'll always receive files every hour and everyday. :) Thanks |
| All times are GMT -4. The time now is 1:39 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC