CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

problems with string.h ???

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
small_chick



Joined: 17 Jul 2012
Posts: 53

View user's profile Send private message

problems with string.h ???
PostPosted: Thu Jul 19, 2012 2:06 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jul 19, 2012 3:09 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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