c++ - exception thrown with sqlite select statement -
i willing access particular element present in coloumn in sqlite database in order achieve have used select statement
char *query = {0}; strcat(query, "select ");//exception thrown here strcat(query, (char*)arr);//the value asscessed strcat(query, " cars");
but throwing exception in ucrtbased.dll why?
update
i have referred answer here , tried this,char* line1 = "select "; char* line2 = (char*)arr; char* line3 = " cars"; size_t len1 = strlen(line1); size_t len2 = strlen(line2); size_t len3 = strlen(line3); char *query = (char*)malloc(len1 + len2 + len3 + 1); if (!query) abort(); memcpy(query, line1, len1); memcpy(query + len1, line2, len2); query[len1 + len2 + len3] = '\0';
but found i've done wrong(because out put jumps else statement means invalid sqlite statement) not figure out kindly me.
i referred tutorial @ cplusplus.com not figure out thank you
you have not allocated memory query
, trying copy characters it. can create variable on stack char query[256] = {0};
if size known. else can allocate memory dynamically using new[]
, release using delete[]
.
Comments
Post a Comment