0

Hey guys I'm having a little problem with reading from a text file, here's how the text is formatted:

random string$52$44$5$abc
random string$52$44$5$abc_def
random string$52$44$5$abc_defgh

this code is what I use to read the text

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

char name[100][100];
char position [100][100];
//char position2[100][100];
int height[100],weight[100],teamnumber[100];
int index = 0;


void open(){
FILE*f = fopen ("data.txt","r");
if (fopen ("data.txt","r")==NULL){
puts ("File not found");
}else{
	while(!feof(f)){
fscanf(f,"%[^$]$%d$%d$%d$%s\n",name[index],&height[index],&weight[index],&teamnumber[index],position[index]);
		index++;
	}
	fclose(f);
}

}

now no matter what i do i can't get rid of the _ symbol from abc_def...
i want the last string output to look like this: abc def instead of abc_def..please help

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by WaltP
0

i want the last string output to look like this: abc def instead of abc_def..please help

How about using strtok and set "_" as a delimeter

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.