User Profile

Collapse

Profile Sidebar

Collapse
Kazzie
Kazzie
Last Activity: Jun 12 '08, 08:11 PM
Joined: Jul 24 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Kazzie
    started a topic Casting
    in C

    Casting

    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.
    ...
    See more | Go to post

  • Kazzie
    started a topic Clear vector
    in C

    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...
    See more | Go to post

  • Kazzie
    started a topic Data structure/Vector
    in C

    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...
    See more | Go to post

  • Kazzie
    replied to Reading from text files
    in C
    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
    See more | Go to post

    Leave a comment:


  • Kazzie
    replied to Reading from text files
    in C
    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...
    See more | Go to post

    Leave a comment:


  • Kazzie
    started a topic Reading from text files
    in C

    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);
    ...
    See more | Go to post
    Last edited by sicarie; Jul 24 '07, 01:03 PM. Reason: Code tags
No activity results to display
Show More
Working...