i write a function for find table name in sql query string.
my code
char* SQLParser_GetTable(char *query)
{
char *str = "";
char *FROM="FROM";
if(strstr(query, FROM))
{
char *e;
int index;
e = strchr(query, 'F');
index = (int)(e - FROM);
str=substring(str,index+4,5);
}
return str;
}
main.c
query = "SELECT * FROM TABLE1";
char *tbl=SQLParser_GetTable(query);
but this code retun full string not table name.
MY code must return "TABLE1".
e = strchr(query, 'F'); index = (int)(e - FROM);?