我写了代码从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

查看:157
本文介绍了我写了代码从Unix的Excel工作表中读取数据,但是我遇到了错误,有人可以帮我解决这个问题吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了一个代码,当我编译它时出现错误,请按照以下说明帮助我解决这个问题..


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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆