Welcome to G4EF. Here comes the code
Code:
#define MAX_LINE_SIZE 100
int main()
{
FILE *fs;
fs=fopen("xyz.dat","r");
if(fs==NULL)
{
printf("Cannot open source file");
return 0;
}
char *ch = new char[MAX_LINE_SIZE];
while (fgets( ch, MAX_LINE_SIZE, fs ))
{
printf("%s",ch);
char tmpBufX[MAX_LINE_SIZE];
char tmpBufY[MAX_LINE_SIZE];
for(int i = 0;ch[i] != ','; i++)
{
tmpBufX[i] = ch[i];
}
tmpBufX[i++] = '\n';
for(int j = 0;ch[i] != '\n'; i++,j++)
{
tmpBufY[j] = ch[i];
}
tmpBufY[j] = '\n';
double x = atof(tmpBufX);
double y = atof(tmpBufY);
}
fclose(fs);
return 0;
}