Comparing Strings
Posted: Tue May 24, 2011 6:44 pm
Hi, i have 2 strings that i would like to compare,
The first string called "in_string" is the data being received, in that string is 4 characters, e.g "STID"
The second string is called "STRING" and is in a string manipulation box, STRING = "STID"
OK, so i send my 4 characters STID and it stores them into the array,
After reading posts on the forum the only way i can find to compare them is to compare each character within the array using this.
(in_string[1] =STRING[1]) && (in_string[2] =STRING[2]) && (in_string[3] =STRING[3]) && (in_string[4] =STRING[4])
This works but seems a bit excessive, just dont want to do this if i needed say 10 characters,
So basically, is there a way to compare an entire string in a simpler way?
The first string called "in_string" is the data being received, in that string is 4 characters, e.g "STID"
The second string is called "STRING" and is in a string manipulation box, STRING = "STID"
OK, so i send my 4 characters STID and it stores them into the array,
After reading posts on the forum the only way i can find to compare them is to compare each character within the array using this.
(in_string[1] =STRING[1]) && (in_string[2] =STRING[2]) && (in_string[3] =STRING[3]) && (in_string[4] =STRING[4])
This works but seems a bit excessive, just dont want to do this if i needed say 10 characters,
So basically, is there a way to compare an entire string in a simpler way?