默认启用忽略空字符 [英] null character(s) ignored enabled by default
问题描述
我正在尝试用数组实现堆栈!每次我执行程序时都运行良好,但我收到警告,因为默认启用忽略空字符
I am trying to implement stack with array! Every time i execute the program runs fine but i am getting warning as null character(s) ignored enabled by default
这个警告是什么意思?..我做错了什么?
What does this warning mean?.. what am i doing wrong?
我的代码是:
#include<stdio.h>
#include<stdlib.h>
# define MAX 10
int top=-1;
int arr[MAX];
void push(int item)
{
if(top==MAX-1)
{
printf("OOps stack overflow:\n");
exit(1);
}
top=top+1;
arr[top]=item;
}//warning
int popStack()
{
if(top==0)
{
printf("Stack already empty:\n");
exit(1);
}
int x=arr[top];
top=top-1;
return x;
}
void display()
{
int i;
for(i=top;i>=0;i--)
{
printf("%d ",arr[i]);
}
return;
}
int peek()
{
if(top==-1)
{
printf("\nEmpty stack");
exit(1);
}
return arr[top];
}
int main()
{
int i,value;
printf(" \n1. Push to stack");
printf(" \n2. Pop from Stack");
printf(" \n3. Display data of Stack");
printf(" \n4. Display Top");
printf(" \n5. Quit\n");
while(1)
{
printf(" \nChoose Option: ");
scanf("%d",&i);
switch(i)
{
case 1:
{
int value;
printf("\nEnter a value to push into Stack: ");
scanf("%d",&value);
push(value);
break;
}
case 2:
{
int p=popStack();
printf("Element popped out is:%d\n",p);
break;
}
case 3:
{
printf("The elements are:\n");
display();
break;
}
case 4:
{
int p=peek();
printf("The top position is: %d\n",p);
break;
}
case 5:
{
exit(0);
}
default:
{
printf("\nwrong choice for operation");
}
}
}
return 0;
}//warning
我使用的是 Dev C++ IDE.
I am using Dev C++ IDE.
推荐答案
在你的源代码文件的某处你有字节值为 0 的字符(ASCII NUL 字符).这在大多数文本编辑器中是不可见的.
Somewhere in your source code file you have character with the byte value 0 (the ASCII NUL character). Which will be invisible in most text editors.
编译器 (gcc) 只是告诉您它忽略了该字符 - 这实际上不应该出现在您的源代码中.
The compiler (gcc) is just telling you that it ignored that character - which really shouldn't be there in your source code .
您可以在十六进制编辑器中打开您的文件,找出该字符的位置并修复它,或者删除您的源文件并从您在此处发布的代码中复制粘贴回来.
You could open your file in a hex editor, figure out where that character is and fix it, or delete your source file and copy paste it back from the code you posted here.
这篇关于默认启用忽略空字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!