Empty characters are ignored by default

I am trying to implement a stack with an array! Every time I execute a program, it runs fine, but I get a warning when empty characters are ignored by default.

What does this warning mean? .. What am I doing wrong?

My code is:

#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

I am using Dev C ++ IDE.

+4
source share
3 answers

Somewhere in your source code there is a character with a byte value of 0 ( ASCII NUL character ). Which will be invisible in most text editors.

The compiler (gcc) simply tells you that it ignored this character, which really should not be in the source code.

, , , , , .

+9

, . , - , , 16- Unicode.

( Linux), . geany ( ) , , UTF/UCS 16, "" UTF8. , , .

, UCS16 ASCII .

+11

, , .

, , Linux, Visual Studio Windows, UTF-16. g++ , UTF-8, .

iconv (Linux)

iconv myfile -f UTF-16 -t UTF-8 > myfile

file myfile
+1
source

Source: https://habr.com/ru/post/1658183/


All Articles