Possible Duplicate:
memcpy and malloc to print out a string
I need to find the number of characters in a line of a text file after a '=' sign until the end of the line or the '#' symbol. I then need to work backwards till I reach the first non blankspace and use memcpy
to print out the string.
Example: if the line said: myprop=this is a sentence #value
, I need it to print out :"this is a sentence". here is the code after I open the file and malloc it.
while(fgets(buffer, 1024, fp) != NULL)
{
if((strstr(buffer, propkey)) != NULL)
{
for (
//need help here
memcpy(value, buffer + 7, 7); //the 7 represents the # of characters till the equal sign
printf("\nvalue is '%s'\n", value);
}
}