【发布时间】:2017-12-16 10:33:05
【问题描述】:
我的程序出现编译器错误。我将 Dev-C++ 与 -c99 -wall 和 -pedantic 一起使用。
#include <stdio.h>
#include <stdlib.h>
int main(){
int size,dial,isListEmpty=0,init,i,variableSize,totalSize=0;//Some values I am using
printf("Welcome to your New Phone ! Please select the size of contact list\n");//Welcome Message
scanf("%d", &size);//input of size
int *listFirstName = (int*)malloc(size*sizeof(int));//Last name (in numbers)
int *listLastName = (int*)malloc(size*sizeof(int));// First name in numbers
int *listNumber = (int*)malloc(sizeof(int));// the phone number
for (init=0 ; init< size ; init++){//initialization of arrays
listFirstName[init]=-1;
listLastName[init]=-1;
listNumber[init]=-1;
}
这是编译器显示错误的地方。
if (dial==3){
int linearAnswer,possibleLN=0, possibleFN=0,flag=0,j=0;
printf("Would you like to search by Last Name , First Name? Please press 1 or 2\n");
scanf("%d",&linearAnswer);
if(linearAnswer==1){
scanf("%d",&possibleLN);
while(j<size){
if(listLastName[j]==possibleLN){
variableSize=j+1;
printf("%d",variableSize);
printf("\nLast Name:%d\t",&listLastName);
printf("First Name:%d\t",&listFirstName);
printf("Phone Number:%d",&listNumber);
flag=1;
}
j++;
}
编译器错误:
[警告] 格式 '%d' 需要类型为 'int' 的参数,但参数 2 的类型为 'int **' [-Wformat=]
该程序的作用:它复制了 1990 年代手机的一些基本功能。首先,用户选择联系人列表的大小。然后他可以添加联系人、查找联系人或列出所有联系人或退出。
编辑:删除图片并添加更多细节
【问题讨论】:
-
我忘了补充,初始化中的 for 循环确实用括号关闭。图片中没有显示。
-
不要在图片中提供源代码或错误消息 - 将它们作为格式正确的文本提供给您的问题,否则很多人甚至不会看您的代码。
-
“我忘了”试试edit。
-
这似乎是一个警告,而不是错误。检查您的库/可执行文件是否正在生成。