I´m stuck here. I´m trying to get a single word from an array.
After the text "Sometext10" comes a word of 6 letters, which I want to get.
I don´t know what is wrong with this code.
I always get segmentation fault, when it comes to run the strncpy command: strncpy (blu,tmp1,len);
Can someone help me with this problem?
Expand|Select|Wrap|Line Numbers
- void get_acid(char blu[50])
- {
- const char *message = array.text;
- const char *smallstring1 = "Sometext10";
- char *ptr1;
- ptr1 = strstr(message, smallstring1);
- char *tmp1 = ptr1+10; //beginning of word
- int len = 6; //length of word
- strncpy (blu,tmp1,len);
- blu[len]='\0';
- }