Split string in sequential file to add a tabstop between the strings...
Hey everyone, I have the following code and trying to figure out a way to split the string, "Brown 3.75, Jones 4.00, etc. and then add a tabstop between them for printing. Is there a simple command or way to do this? Thanks in advance!
Code:
#include <stdio.h>
#include <stdlib.h>
#define N 100
int main()
{
FILE *fP;
char str[N], *c;
if ((fP = fopen("names.dat", "r")) == NULL)
{
printf("%s not opened", "names.dat");
exit(EXIT_FAILURE);
}
do {
c = fgets(str, N ,fP);
if (c != NULL)
printf("%s\n", str);
}
while (c != NULL);
fclose(fP);
return 0;
}