H
Harini
Ive written this sample code in Dev C++ and use fgets to read from a
external file. My compiler crashes with a windows error. Could somebody
help me out
a sample of the usage of of fgets in my code is listed below
#include<stdio.h>
#include<stdlib.h>
#include <string.h>
int main()
{
FILE *fd;
char line[200];
int count=0;
char *tmp;
int zip = 0;
int uzip=0;
printf("\nPlease enter your zip code : ");
scanf("%d", &uzip);
uzip = uzip/100;
printf("uzip = %d",uzip);
fd = fopen("c://Dev-Cpp/SA/STANDARD-SAMPLE1.csv","r");
while(fgets(line,200,fd) != NULL)
{
tmp = strtok(line,",");
zip = atoi(tmp);
printf("zip=%d\n",zip);
count++;
}
printf("# lines=%d",count);
}
thank you
external file. My compiler crashes with a windows error. Could somebody
help me out
a sample of the usage of of fgets in my code is listed below
#include<stdio.h>
#include<stdlib.h>
#include <string.h>
int main()
{
FILE *fd;
char line[200];
int count=0;
char *tmp;
int zip = 0;
int uzip=0;
printf("\nPlease enter your zip code : ");
scanf("%d", &uzip);
uzip = uzip/100;
printf("uzip = %d",uzip);
fd = fopen("c://Dev-Cpp/SA/STANDARD-SAMPLE1.csv","r");
while(fgets(line,200,fd) != NULL)
{
tmp = strtok(line,",");
zip = atoi(tmp);
printf("zip=%d\n",zip);
count++;
}
printf("# lines=%d",count);
}
thank you