brianm
Joined: 08 Mar 2008 Posts: 17
|
string comparison |
Posted: Sun Apr 26, 2009 12:32 pm |
|
|
I am not that versed in c programming.
I am trying to take input from an rs232 connection and compare it to a string constant (a word).
This example does not compile....it is my understanding the I compare the string from the 'gets' and compare it to the constant. I have even tried strcmp ("word","word")...I am clearly not understanding something.
Someone please set me on the right course.
Thanks a million.
Code: |
#include <16F690.h>
#fuses INTRC_IO, NOWDT, NOBROWNOUT, PUT, NOMCLR
#use delay(clock=8000000)
#use rs232(baud=4800, xmit=PIN_B7, rcv=PIN_B5)
#include <string.h>
//=============================
void main()
{
char input[6];
int x;
printf("Password: ");
while(1)
{ gets(input);
puts(input);
x = strcmp(input, "word");
if (x == 0)
printf ("strings are the same \n\r");
printf ("password typed is %s. \n\r",input);
}
}
|
|
|