int main(int argc, char **argv)
{
char rid[15];
char buffer[100];
char a[100];
char b[100];
DIR *h;
struct dirent *dir;
h = opendir(".");
if (h)
{
while ((dir = readdir(h)) != NULL)
{
FILE *file = fopen (dir->d_name , "r" );
printf("%s\n", dir->d_name);
}
closedir(h);
}
char c[100];
char d[100];
char temp[250]="";
char *token;
int comchk = 0;
int lino ;.
char ch[20],
ch1[20];
char value[250],
value1[250],
value2[250],
value3[250];
char query[250]="";
int i;
static const char filename[10];
MYSQL *con = mysql_init(NULL);
if (con == NULL)
{
fprintf(stderr, "%s\n", mysql_error(con));
exit(1);
}
if (mysql_real_connect(con, "localhost", "madhu", "cmmacsgps", "rinex", 0, 0) == NULL)
{
finish_with_error(con);
}
if (mysql_query(con, "INSERT INTO rinex1 VALUES('','no','no','no','no','no','no','no','no','no','no','no','no')"))
{
finish_with_error(con);
}
int nrid = mysql_insert_id(con);
sprintf(rid, "%d", nrid);
printf("enter filename\n");
scanf("%s",filename);
FILE *file = fopen ( filename, "r" );
if ( file != NULL )
{
char line [250]; /* or other suitable maximum line size */
char line1 [250];
char *token1;
char *token2;
int tabno=0;
while ( fgets ( line, sizeof line, file ) != NULL ) /* read a line */
{
lino =lino+1;
strcpy(line1,line);
substring(60, 80, line1, a, sizeof a);
substring(0, 60, line1, b, sizeof b);
strcpy(c,a);
}
fclose ( file );
}
mysql_close(con);
exit(0);
}`
`
答案 0 :(得分:0)
如果在windows下实现,请阅读使用 dirent.h
http://pubs.opengroup.org/onlinepubs/007908799/xsh/dirent.h.html
您将要检查readdir函数并检查示例。 使用它来获取文件的名称,而不是应用每个文件的其余过程,