#1
  1. <!--REMOTE_ADDR-->
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Location
    Cali4nia
    Posts
    162
    Rep Power
    11

    Need To Compare 2 strings?


    I am trying to create a C++ program which reads a c++ program from a file, finds the assignment statements and makes a list of all the variables that are on either side of the = sign.
    Code:
    example:
    
    Assignment Statements                    LEFT             RIGHT
    
    good = bad;                                      good               bad
    
    i = sqrt(num + 67) + good/num;          i              num, good,num
    I plan (it might b wrong) to read all the words starting with alphabets and compare them with a list of all the keywords and thus find out the variables....but i want to know how do i compare the strings (string functions) in Visual C++6.0

    ThanQ

    P.S. I am Kinda Newbie
    Last edited by mr_______bond; June 28th, 2003 at 10:16 PM.
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,595
    Rep Power
    4207
    >> i want to know how do i compare the strings
    For char arrays, you're looking for the strcmp() function. Check out the documentation for this function in MSDN with this link:
    http://msdn.microsoft.com/library/de...c_._mbscmp.asp
    I think the next link will also be useful to you. It consists of a list of string manipulation routines for char arrays.
    http://msdn.microsoft.com/library/de...nipulation.asp

    Note that, if you use CString or string class objects, instead of char arrays, then the == operator can be used to compare two instances of these classes.

    Hope this helps.
    Last edited by Scorpions4ever; June 29th, 2003 at 01:10 AM.

IMN logo majestic logo threadwatch logo seochat tools logo