copy one string to another string up to some no of characters

char* category;//i'll pass some string using function
for( i=0;i<noOfRecords;i++){
char string[30];
char* mystring;
size_t len=strlen(category);
strcpy(mystring,category,len-1);
sprintf(string,"%s",labValueRecords->category);

labValueRecords++;
if(strcmp(string,mystring)==0){
count++;
}
}




when i run this it giving an error like
The variable 'mystring' is being used without being initialized.




plz help me
thanks
regards yakub
mystring is a pointer to random memory, which may or may not be writable, so when you use strcpy() and try to copy to it, you could be writing to invalid memory.
thank you dude ...
Topic archived. No new replies allowed.