How about this, wrote it up ages ago for reading froma file though
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
char c, *buffer;
int n = 0, x, size;
FILE *file;
file = fopen("a_test_file.txt", "rb");
if(file == NULL) perror("Error opening file!");
else {
while(c != EOF) {
c = fgetc(file);
if(c == ';') {
x = ftell(file);
}
}
fseek(file, 0, SEEK_END);
size = ftell(file);
rewind(file);
buffer = (char*) malloc(size-x);
if(buffer == NULL) perror("Error allocating memory!");
fseek(file, x, SEEK_SET);
fread(buffer, 1, size-x, file);
fclose(file);
printf("File Size: %i\nByte: %i\nBytes Left: %i\nText After: %s\n", size, x, size-x, buffer);
free(buffer);
}
return 0;
}
That will search inside a file, i wrote this ages ago, you can easily substitue the reading from the file to the reading of a string...
Hope this helps