我写了代码从Unix的Excel工作表中读取数据,但是我遇到了错误,有人可以帮我解决这个问题吗 [英] I Have Written A Code To Read Data From Excel Sheet In Unix But I Am Getting An Error Could Somebody Help Me To Sort Out This
问题描述
我已经编写了一个代码,当我编译它时出现错误,请按照以下说明帮助我解决这个问题..
sosdt011 @ sosdt011:〜/mysample $ gcc -o fir first.c
first.c:在"main"函数中:
first.c:14:3:警告:格式'%s'期望类型为'char *',但是参数3的类型为'char(*)[300]'[-Wformat =]
fscanf(fp,%s%s%s",& name,& city,&dept);
^
first.c:14:3:警告:格式为'%s'的参数类型为'char *',但是参数4的类型为'char(*)[300]'[-Wformat =]
first.c:14:3:警告:格式'%s'期望类型为'char *',但是参数5的类型为'char(*)[300]'[-Wformat =]
I have written a code and when i am compiling it i am getting an error as follow kindly help me to sort out this..
sosdt011@sosdt011:~/mysample$ gcc -o fir first.c
first.c: In function ‘main’:
first.c:14:3: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘char (*)[300]’ [-Wformat=]
fscanf(fp,"%s%s%s",&name,&city,&dept);
^
first.c:14:3: warning: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘char (*)[300]’ [-Wformat=]
first.c:14:3: warning: format ‘%s’ expects argument of type ‘char *’, but argument 5 has type ‘char (*)[300]’ [-Wformat=]
推荐答案
gcc -o fir first.c
first.c:在"main"函数中:
first.c:14:3:警告:格式'%s'期望类型为'char *',但是参数3的类型为'char(*)[300]'[-Wformat =]
fscanf(fp,%s%s%s",& name,& city,&dept);
^
first.c:14:3:警告:格式为'%s'的参数类型为'char *',但是参数4的类型为'char(*)[300]'[-Wformat =]
first.c:14:3:警告:格式'%s'期望类型为'char *',但是参数5的类型为'char(*)[300]'[-Wformat =]
gcc -o fir first.c
first.c: In function ‘main’:
first.c:14:3: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘char (*)[300]’ [-Wformat=]
fscanf(fp,"%s%s%s",&name,&city,&dept);
^
first.c:14:3: warning: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘char (*)[300]’ [-Wformat=]
first.c:14:3: warning: format ‘%s’ expects argument of type ‘char *’, but argument 5 has type ‘char (*)[300]’ [-Wformat=]
您正在将&
(addresssof运算符)添加到阵列名称中,这是不正确的.请重新阅读您的C ++参考手册,以将数组名称用作指针.
You are adding the &
(addresssof operator) to your array names, which is incorrect. Go and reread your C++ reference manual for the use of array names as pointers.
这篇关于我写了代码从Unix的Excel工作表中读取数据,但是我遇到了错误,有人可以帮我解决这个问题吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!