User Profile

Collapse

Profile Sidebar

Collapse
bnchs
bnchs
Last Activity: Apr 7 '08, 01:46 PM
Joined: Mar 23 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • bnchs
    started a topic Help with Parent Pointer in Recursive AVL Tree
    in C

    Help with Parent Pointer in Recursive AVL Tree

    This is C code. I am trying to fill each node's Parent field with its parent because I am drawing nodes to the screen. However, I have not been able to get this working. Reading the output from the code and tracing it, it seems that the code does not continue recursing down into the tree to insert. Can someone please point me to what is wrong and help me understand why it is wrong? Thank you.

    Code:
    struct AvlNode* Insert( gint X,
    ...
    See more | Go to post

  • bnchs
    started a topic Using stringstream in C++
    in C

    Using stringstream in C++

    I have an input file that has lines containing integers, characters and strings that has to be parsed to extract information from it. I am using an istringstream to do this but am having problems getting it to work.

    The lines can look like:

    2 : 2 5 5 8
    2 = 2 * 2
    show 2

    I already have a part working where the char colon contains ':' and poly and location are integers...
    See more | Go to post

  • bnchs
    replied to C++ fstream I/O
    in C
    Unfortunately, I just discovered a runtime bug, where I am getting results that two strings are not anagrams because one has whitespace in it. By any chance is there some function that can strip whitespace from a string?

    Or, since a 'space' has a lower ASCII value than letters (it would be a matter of simply removing the first index from the string), a way to find whitespace inside a string ?
    See more | Go to post

    Leave a comment:


  • bnchs
    replied to C++ fstream I/O
    in C
    Yes, and I found a solution by sorting the strings and then using compare() to compare the strings. If compare () returns 0, then they are anagrams, else they are not.
    See more | Go to post

    Leave a comment:


  • bnchs
    replied to C++ fstream I/O
    in C
    The algorithm I am trying to implement is:
    first to check if the strings are equal in size. If not, then they can't be anagrams and return false. Next, go through both strings and check if every character in the first string is in the second string. If so, they are anagrams, else, they are not.

    I think that checking if s[i] == s[j] is the problem and am stuck here.


    Code:
    bool are_anagrams(string s,
    ...
    See more | Go to post

    Leave a comment:


  • bnchs
    replied to C++ fstream I/O
    in C
    That did it. Thanks for your help.
    See more | Go to post

    Leave a comment:


  • bnchs
    replied to C++ fstream I/O
    in C
    No that doesn't work because it prints out the same line.
    See more | Go to post

    Leave a comment:


  • bnchs
    started a topic C++ fstream I/O
    in C

    C++ fstream I/O

    I am trying to store the current line and the next line of a file into strings to do comparisons between them. However, I can't and don't know how to get the next line from the file into the string next_line. Any suggestions? Thanks.

    Code:
    string line, cur_line, next_line ;
     while (INFILE)
     {
      while( getline(INFILE, line) )
      {
       
       if(isdigit(line[0])) //Ignores lines that start with
    ...
    See more | Go to post

  • bnchs
    started a topic C++ fstream
    in C

    C++ fstream

    I am have tried unsuccessfully to remove or ignore lines that contain integers from an input file. This is what I am using to extract lines from the file. I have looked up the ignore() function but I don't think that will help me do this. Does anyone have any suggestions? Thanks.

    Code:
     
    while (INFILE)
    {
     getline(INFILE, line) ;
    ...
    ...
    }
    The input file contains data...
    See more | Go to post
No activity results to display
Show More
Working...