![]() |
| | #1 |
| Registered User Join Date: Oct 2005
Posts: 13
| Parsing Text File and gathering input variables I have a text file which contains some text. Now I want to get the some variables out of the TextFiles. The format of the file is something like this: MyVariables a,b,c,d ..... .... ... end So now I want to parse the text file and get a,b,c,d into a array or a queue or stack (some sort of collection). At this point I am able to read the file using the following code: Code: int main() {
FILE *fp;
char name[25];
char buff[BUFSIZ];
float num;
char ch;
if((fp=fopen("AboutMe.txt","r"))==NULL)
{
perror("File cannot be opened");
getchar();
}
while((ch = fgetc(fp)) != EOF)
{
if(ch == 13)
printf("Line break has been found");
printf("%c",ch);
}
getchar();
return 0;
Thanks, |
| azamsharp1 is offline | |
| | #2 |
| Learner Join Date: Aug 2005
Posts: 335
| read it line by line with sscanf and store it in a array |
| Axel is offline | |
| | #3 |
| Registered User Join Date: Oct 2005
Posts: 13
| Thanks Axel. I will try that !! |
| azamsharp1 is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| gathering input as array | twans | C Programming | 4 | 12-12-2001 11:27 AM |
| Help!!!!!!!! | Shy_girl_311 | C++ Programming | 3 | 10-10-2001 02:22 PM |