//Function to store select_field
void store_field(int num_fields, unsigned long *lengths,
MYSQL_ROW row, char elect_type[10][100])
{
//Storing select_field below
int i,j,k,g;
for( i=1;i < num_fields;i=i+10)
{
// i+10 so that loop is executed one time only,
// i=1 bcoz 2nd entry is select_type
for (j=0;j<lengths[i];j++)
{
if (row[i] != NULL)
{
select_type[k][j] = *row[i];
row[i]++;
}
if (row[i] == NULL)
{
select_type[k][j]= '\0';
printf ( "NULL\n");
break; // row[i] is null for fields containing NULL
}
}
for (j;j<100;j++)
{
select_type[k][j]='\0';
}
// setting every other empty field in current row
// of select_type to NULL
}
k++;
}
g = k; //HERE I AM GETTING THE ERROR
for (k;k<10;k++){for(j=0;j<100;j++)
{
select_type[k][j]='\0';
}
}
我已经在函数中声明了
k
,但我得到了错误。 最佳答案
你有一个额外的右括号。线路
} g=k; **//HERE I AM GETTING THE ERROR**
关闭函数。
我冒昧地格式化了代码缩进。如果您保持良好的缩进,应该清楚
}
不合适:#include <stdio.h>
#include <ctype.h> // For tolower() function //
//Function to store select_field
void store_field(int num_fields,unsigned long *lengths,MYSQL_ROW row,char select_type[10][100]){
//Storing select_field below
int i,j,k,g;
for( i=1;i < num_fields;i=i+10){ // i+10 so that loop is executed one time only , i=1 bcoz 2nd entry is select_type
for (j=0;j<lengths[i];j++){
if (row[i] != NULL){ select_type[k][j] = *row[i];
row[i]++;
}
if (row[i] == NULL) { select_type[k][j]= '\0'; printf ( "NULL\n");break; // row[i] is null for fields containing NULL
}
}for (j;j<100;j++){select_type[k][j]='\0';} //setting every other empty field in current row of select_type to NULL
} k++;
// } g=k; **//HERE I AM GETTING THE ERROR**
for (k;k<10;k++){for(j=0;j<100;j++){select_type[k][j]='\0'; }}
}
关于c - 函数中未声明的变量,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17467013/