URI:
   DIR Return Create A Forum - Home
       ---------------------------------------------------------
       Essentials of Scientific Computing 2013
  HTML https://esc2013.createaforum.com
       ---------------------------------------------------------
       *****************************************************
   DIR Return to: Programming Questions
       *****************************************************
       #Post#: 3--------------------------------------------------
       Comparing Two Strings
   DIR By: mathnathan
       Date: July 3, 2013, 12:46 pm
       ---------------------------------------------------------
       Here is the code we wrote in class for comparing to character
       arrays...
       
       --- Code ---
       
       #include <stdio.h>
       
       int main() {
       
       char name1[7] = "Nathan";
       char name2[7] = "Nahtan";
       bool stringFlag = true;
       
       for( int i = 0; i < 7; i++ ) {
       if( name1[i] != name2[i] ) { // If any letters are not
       equal, set the flag to false and exit the loop
       stringFlag = false;
       break;
       }
       }
       
       if ( stringFlag ) {
       printf ( "Strings are equal!\n" );
       }
       else {
       printf ("Strings not equal!\n" );
       }
       
       return 0;
       }
       
       --- End Code ---
       *****************************************************
       Page 1 of 1