I am trying to read a line in from a text file which contains strings of characters and intergers. I read the line into a char*. I then need to parse the line. When it comes to storing the intergers as an int, I need to cast them as they have been read using a char*.
I know casting a char* as an int which is already an int will not give me the correct value of the integer.
So how do I store the intergers as int.
...
User Profile
Collapse
-
Clear vector
I have a structure
struct Rulestrc
{
char* rulen;
vector<char*>v6 ;
char* resp;
};
I then create an array of structures - Rulestrc tp[100]. However the content of tp is constantly changing during the run of my program, therefore I need to clear the contents of vector. I do this:
for (y=0; y<100; y++)
{
if (tp[y].v6.size()) // because some of the... -
Data structure/Vector
I am trying to read a file and then store the results in a data structure. One of the members of the structure is a vector. I use the following to push back the data 'p' into the vector 'v1'.
Assume structure called Rulestrc
Rulestrc* tp = NULL;
other coding
tp -> v1.push_back(p) ;
The code compiles but does not run. I know it has something to do with the vector but I am... -
The thing is I have two columns in my text file and I'm only interested in the second one at the moment. That is why I used sscanf() to access the second column. How can I then read in the sentences. Thanks -
The thing is I have two columns in my text file and I'm only interested in the second one at the moment. That is why I used sscanf() to access the second column. How can I then read in the sentences. Thanks...Leave a comment:
-
Reading from text files
Hi
I am trying to read in one sentence at a time from a text file, perform a number of methods on it and then move to the next sentence and so on. The text file looks like this:
rule1 sentence 1
rule2 sentence 2
etc
and the code looks like this:...Code:char text[256], str[256]; fstream fid2; char filename3[]="c......"; fid2.open(filename3, ios::in);
No activity results to display
Show More
Leave a comment: