954,492 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

some programmnig help for c code in linux

i am writing a code which is as follows:

#include <stdio.h>

int main(void)
{
    char buffer[2500];
    FILE * myfile;
	
    myfile = fopen("/home/csgrads/akhan015/desktop/benchmark/coverage/test0/stmt.txt","r");
	
    while (!feof(myfile))
    {
        fgets(buffer,2500,myfile);
        printf("%s",buffer);
    }
	
    fclose(myfile);
    
    return 0;
}

1.in this code i am accessing a folder to read a text file. this test0 folder is only 1 folder of the 1500 folders i have to read in which i have to open and compare 1500 txt files which are in test0... test1500. i can only access the text file through path( this is the only way i know to access the text file placed in a folder).please can someone tell how can i access 1500 folders in a loop or some other way. a code snippet would be really appreciated.

2.for each of 1500 text files and i have to compare the strings in them such that if two files have similar strings then i keep only 1 of it in a buffer and compare it with the next file. if theses two have some strings different then i will unite them.and remember the folder name e.g test 19, test 100 in a separate file.if somebody has an idea abt it please help me.

amnakhan786
Newbie Poster
6 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

1. Use snprintf to generate the appropriate path name.

2. Think of an appropriate data structure, that's what this exercise is all about.

Rashakil Fol
Super Senior Demiposter
Team Colleague
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 177
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: