Undeclared Variable Error
Hello,
I am writing a query for database
here is the code..
Code:
char *create_query(char *name, int perc)
43 {
44 char *defl = "INSERT INTO student_profile VALUES ('";
45 char *def2 = "',";
46 char *def3 = ");";
47 char buf[33];
48 char *query = (char *)malloc(300);
49 strcat(query,def1);
50 strcat(query, name);
51 strcat(query, def2);
52
53 itoa(perc, buf, 10);
54
55 strcat(query, buf);
56 strcat(query, def3);
57
58 return query;
59 }
I am getting error
03_Insert_into_Table.c: In function ‘create_query’:
03_Insert_into_Table.c:49:2: warning: incompatible implicit declaration of built-in function ‘strcat’
03_Insert_into_Table.c:49:15: error: ‘def1’ undeclared (first use in this function)
03_Insert_into_Table.c:49:15: note: each undeclared identifier is reported only once for each function it appears in
Even though i have declared def1 as char *, why im getting that error...
also what is wrong with strcat....
Thxn!!