String array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • 19831030
    New Member
    • Jul 2007
    • 9

    String array

    I wanna put string into array ,but I also wanna compare whole string using strcmp.So using 2 dim char array I can't do that,because if I use it I have to compare 2 strings by using char by char.But I wanna to compare whole string by using strcmp.Also I wanna to store a string.
    First time I use argv for store string.But I wanna some selected string store again with full fill above condition.(ie I wanna store array as whole.not char by char). Can I use again argv for store string or are there any way to store string.
  • Meetee
    Recognized Expert Contributor
    • Dec 2006
    • 928

    #2
    Originally posted by 19831030
    I wanna put string into array ,but I also wanna compare whole string using strcmp.So using 2 dim char array I can't do that,because if I use it I have to compare 2 strings by using char by char.But I wanna to compare whole string by using strcmp.Also I wanna to store a string.
    First time I use argv for store string.But I wanna some selected string store again with full fill above condition.(ie I wanna store array as whole.not char by char). Can I use again argv for store string or are there any way to store string.
    You can use pointers and arrays. Here is the pseudocode!!

    Code:
    char s[10];
    char ss[10];
    
     //ask user to enter two strings or predefine it!
    
     bool flag = true;
     for (int i = 0; i < 10; ++i ) {
     if ( s[i] != ss[i] ) {
     flag = false;
     break;
     }
     }
     if(flag == false)
     cout << "Not equal";
     else cout << "equal";
    Hope this helps!!

    Regards

    Comment

    Working...