June 28th, 2003, 11:13 PM
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.
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
Assignment Statements LEFT RIGHT
good = bad; good bad
i = sqrt(num + 67) + good/num; i num, good,num
P.S. I am Kinda Newbie
Last edited by mr_______bond; June 28th, 2003 at 11:16 PM.
June 29th, 2003, 02:07 AM
>> 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:
I think the next link will also be useful to you. It consists of a list of string manipulation routines for char arrays.
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 02:10 AM.