|
|
View previous topic :: View next topic |
Author |
Message |
small_chick
Joined: 17 Jul 2012 Posts: 53
|
problems with string.h ??? |
Posted: Thu Jul 19, 2012 2:06 am |
|
|
I'd like to use standard string functions. Although I've added files: string.h. stddef.h, ctype.h , it still has error.You can view the problem in the following picture: http://www.mediafire.com/view/?x7tmj3k3t6v1off !
I don't know how to fix it! I hope someone can help me! thanks!
This is my code:
//*************************************
#include "16F887.h"
#use delay(clock = 4000000)
#use RS232(UART1)
#include "string.h"
//**********************************
void uart_init()
{
setup_uart(9600);
}
//***************************************
void main()
{
char string[30];
uart_init();
while(1)
{
printf("Password: ");
gets(string);
if(strcmp(string,password))
printf("OK");
putc(13);
}
}
//**************************************
//the end!
//*************************************
And the error statement:
*** Error 66 "C:\Users\USER\Desktop\lam_mach\PIC_projects\16F887\CCS C\string.h" Line 382(31,32): Previous identifier must be a pointer
*** Error 12 "main.c" Line 20(18,26): Undefined identifier password |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19484
|
|
Posted: Thu Jul 19, 2012 3:09 am |
|
|
It is telling you exactly what is wrong.....
if(strcmp(string,password))
You have a variable called 'string' declared, but nothing called 'password'. If you want to look for the text "password", then you need to say this:
Code: |
void main(void) {
char string[30];
char password[]="password";
uart_init();
while(1) {
printf("Password: ");
gets(string);
if(strcmp(string,password)) {
printf("OK");
putc(13);
}
}
}
|
Also note how much nicer the post is if you use the 'code' buttons.....
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|