Use pointer subtraction.
char *str = "sdfadabcGGGGGGGGG";
char *result = strstr(str, "abc");
int position = result - str;
int substringLength = strlen(str) - position;
More Related Contents:
- Get a substring of a char* [duplicate]
- Find the Biggest Number in C, BUT with characters
- isnt everything where it should be, why the segmentation fault?
- Removing digits and all punctuation except apostrophe from a string in C
- char c[]=”Albus”; printf(“%c”, c); [closed]
- returning string in C function [closed]
- Returning an array using C
- Is char signed or unsigned by default?
- Are there machines, where sizeof(char) != 1, or at least CHAR_BIT > 8?
- How to do scanf for single char in C [duplicate]
- Convert hex string (char []) to int?
- How to copy a char array in C?
- Determine if char is a num or letter
- Why does strchr take an int for the char to be found?
- In C, why is sizeof(char) 1, when ‘a’ is an int?
- No compiler error when fixed size char array is initialized without enough room for null terminator
- unsigned int and signed char comparison
- Char to int conversion in C
- C: correct usage of strtok_r
- In C, why can’t an integer value be assigned to an int* the same way a string value can be assigned to a char*?
- Convert char array to a int number in C
- Conversion of Char to Binary in C
- C char array initialization: what happens if there are less characters in the string literal than the array size?
- Does C have a string type? [closed]
- Counting number of occurrences of a char in a string in C
- why sizeof(‘a’) is 4 in C? [duplicate]
- assigning more than one character in char
- Char array in a struct – incompatible assignment? [duplicate]
- C split a char array into different variables
- Creating a FORTRAN interface to a C function that returns a char*