Stack

T

Tarique

Hello all.I am trying to implement a stack which can store either
integer or float values.

The code is given below:

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define STACKSIZE 100
#define INT 1
#define FLOAT 2
#define STRING 3


struct stackelement{
int etype; /*etype equals INT,FLOAT,STRING*/
/*depending on the type of the */
/*corresponding element */
union {
int iVal;
float fVal;
/* char *pVal; */
}element;
};

struct stack{
int top;
struct stackelement item[STACKSIZE];
};


void push(struct stack *p,struct stackelement *se,int n)
{
if(p->top == STACKSIZE-1 )
printf("overflow\n");

else
{
if(se->etype == INT)
p->item[++p->top].element.iVal=n;
else if(se->etype == FLOAT)
p->item[++p->top].element.fVal=(float)n;
/*
else if(se->etype == STRING)
p->item[++p->top].element.pVal="T";
*/
}
return;
}

void pop(struct stack *p,struct stackelement *se)
{
if(p->top==-1)
printf("underflow\n");
else
{
if(se->etype == INT)
printf("deleted number is\ %d\n",p->item[p->top].element.iVal);
else if(se->etype == FLOAT)
printf("deleted number is\ %d\n",p->item[p->top].element.fVal);

--p->top;
}
return;
}


void display(struct stack *p,struct stackelement *se)
{
int i;
if(p->top == -1)
printf("stack is empty\n\n");
else
{
if(se->etype == INT)
{
for(i=p->top; i >= 0; i--)
printf("%d\n", p->item.element.iVal\ );
}

else
{
for(i = p->top; i >= 0; i--)
printf("%d\n", p->item.element.fVal);
}
}
return;
}

void menu(void)
{
/*Sub Menu
to accept the options of push /pop etc*/
}



int main(void)
{
int choice_mm ;
struct stackelement se;
struct stack s;
s.top = -1;

/*Main Menu
to accept the choices for int/float type*/

return 0;
}

I am getting the warning:
warning C4133: 'function' : incompatible types - from 'stack *' to
'stackelement *'
whenever i try to call the push /pop/display functions

push(&s,&s_elem,num);
pop(&s,&s_elem);
display(&s,&s_elem);
in the main function
Can anyone please help me out?Thanks
 
J

John Gordon

In said:
struct stackelement se;
struct stack s;
warning C4133: 'function' : incompatible types - from 'stack *' to
'stackelement *'
whenever i try to call the push /pop/display functions
push(&s,&s_elem,num);
pop(&s,&s_elem);
display(&s,&s_elem);
in the main function

Your sample main() function contains no declarations of a variable
called "s_elem". We can't help you until we know this information.
 
T

Tarique

John said:
Your sample main() function contains no declarations of a variable
called "s_elem". We can't help you until we know this information.
Oops! I missed that.s_elem is defined in the "menu" function


void menu(void)
{
int choice;
int flag=1;
int num=0;
struct stack s;
struct stack s_elem;

while(flag)
{
...Menu snipped...
...case statements...
}
return ;
}
 
T

Tarique

Tarique said:
The code is given below:
...snip...

The rest of the code (menu)is given below.
I have changed the definition of the function.The earlier one was
causing the code to fail.


void menu(struct stack *s,struct stack *s_elem)
{
int num=0;
int choice;
int flag=1;

while(flag)
{
printf("Menu");
printf("\n1.Push");
printf("\n2.Pop");
printf("\n3.Display");
printf("\n4.Exit");
printf("\n5.Clear screen\n");
printf("Enter your choice :");
scanfs("%d",&choice);

switch(choice)
{
case 1:
printf("Enter the number to push");
scanfs("%d",&num);
fflush(stdin);
push(s,s_elem,num);/*warning*/
break;
case 2:
pop(s,s_elem); /*warning*/
break;
case 3:
display(s,s_elem);/*warning*/
break;
case 4:
flag=0;
break;
case 5:
system("cls");
break;
default:
printf("wrong choice\n");
}
}
}



int main(void)
{
int choice_mm ;
struct stackelement se;
struct stack s;
s.top = -1;

for(;;)
{
printf("Choose the type of stack:\n");
printf("1.Integer\n");
printf("2.Float\n");
printf("3.String\n");
printf("4.Exit\n");
scanfs("%i", &choice_mm);

switch(choice_mm)
{
case 1:
se.etype=INT;
system("cls");
menu(&s,&se);/*warning*/
system("cls");
break;
case 2:
se.etype=FLOAT;
menu(&s,&se);/*warning*/
break;
case 3:
se.etype=STRING;
menu(&s,&se);/*warning*/
break;
case 4:
exit(0);
break;
default:
printf("wrong input");
}
}
return 0;
}


I am compiling the code with Visual c++ 2008 (express edition) (/as a c
code/)
I am really sorry for the long post but i am still getting the warnings:

warning C4133: 'function' : incompatible types - from 'stack *' to
'stackelement *'

warning C4133: 'function' : incompatible types - from 'stackelement *'
to 'stack *'

kindly Help!
 
W

Walter Roberson

Tarique wrote:
void menu(struct stack *s,struct stack *s_elem) [...]

int main(void)
{
struct stackelement se;
struct stack s;
menu(&s,&se);/*warning*/

The second parameter of your call is &se, which is the address
of a struct stackelement. However, your menu() routine expects
the second parameter to be struct stack *s_elem, which is the
address of a struct stack, not of a struct stackelement.
 
S

spaglia

Hello all.I am trying to implement a stack which can store either
integer or float values.

The code is given below:

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define STACKSIZE       100
#define INT                     1
#define FLOAT           2
#define STRING          3

struct stackelement{
        int etype;      /*etype equals INT,FLOAT,STRING*/
                                /*depending on the type of the */
                                /*corresponding element */
        union {
                int     iVal;
                float   fVal;
        /*      char    *pVal;  */
        }element;

};

struct stack{
        int top;
        struct stackelement item[STACKSIZE];

};

void push(struct stack *p,struct stackelement *se,int n)
{
        if(p->top == STACKSIZE-1 )
         printf("overflow\n");

        else
        {
                if(se->etype == INT)
                        p->item[++p->top].element.iVal=n;
                else if(se->etype == FLOAT)
                        p->item[++p->top].element.fVal=(float)n;
                /*
                else if(se->etype == STRING)
                        p->item[++p->top].element.pVal="T";
                */
        }
        return;

}

void pop(struct stack *p,struct stackelement *se)
{
     if(p->top==-1)
         printf("underflow\n");
     else
     {
                if(se->etype == INT)
                        printf("deleted number is\ %d\n",p->item[p->top].element.iVal);
                else if(se->etype == FLOAT)
                        printf("deleted number is\ %d\n",p->item[p->top].element.fVal);

                --p->top;
     }
     return;

}

void display(struct stack *p,struct stackelement *se)
{
     int i;
     if(p->top == -1)
         printf("stack is empty\n\n");
     else
        {
                if(se->etype == INT)
                {
                        for(i=p->top; i >= 0; i--)
                                printf("%d\n", p->item.element.iVal\ );
                }

                else
                {
                        for(i = p->top; i >= 0; i--)
                                printf("%d\n", p->item.element.fVal);
                }
        }
        return;

}

void menu(void)
{
/*Sub Menu
to accept the options of push /pop etc*/

}

int main(void)
{
        int     choice_mm ;
        struct  stackelement se;
        struct  stack s;
        s.top = -1;

        /*Main Menu
        to accept the choices for int/float type*/      

        return 0;

}

I am getting the warning:
  warning C4133: 'function' : incompatible types - from 'stack *' to
'stackelement *'
whenever i try to call the push /pop/display functions

push(&s,&s_elem,num);
pop(&s,&s_elem);
display(&s,&s_elem);
in the main function
Can anyone please help me out?Thanks


Your display function does not look right to me either.
 
T

Tarique

Tarique said:
Hello all.I am trying to implement a stack which can store either
integer or float values.

The code is given below:
....snip...

Here is the final code:
Works fine in case of Integer n floats.However i lose track of the
character pointer once i exit the push function (in case of strings).
So in case of *Strings* i cannot display the popped string or the
members of the stack at any given time.
Using an extra global variable to keep track also does not help!
It's confusing!!!

PS:ive not really bothered about scanf..Will change that :)



#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define STACKSIZE 100
#define INT 1
#define FLOAT 2
#define STRING 3

struct stackelement{
int etype; /*etype equals INT,FLOAT,STRING*/
/*depending on the type of the */
/*corresponding element */
union {
int iVal;
float fVal;
char *pVal;
}element;
};

struct stack{
int top;
struct stackelement item[STACKSIZE];
};

void push(struct stack *p,struct stackelement *se)
{
int test;
int iValue = 0;
float fValue = 0.0;
char cValue[10];

printf("Enter the number/character to push");
if(se->etype == INT)
scanf("%d",&iValue);
else if(se->etype == FLOAT)
scanf("%f",&fValue);
else if(se->etype == STRING)
{
while((test=getchar())!='\n')
;
fgets(cValue,10,stdin);
}


if(p->top == STACKSIZE-1 )
printf("overflow\n");

else
{
if(se->etype == INT)
p->item[++p->top].element.iVal=iValue;
else if(se->etype == FLOAT)
p->item[++p->top].element.fVal=fValue;
else if(se->etype == STRING)
p->item[++p->top].element.pVal=cValue;
}
return;
}

void pop(struct stack *p,struct stackelement *se)
{
if(p->top==-1)
printf("underflow\n");
else
{
if(se->etype == INT)
printf("Deleted Integer is\ %d\n",p->item[p->top].element.iVal);
else if(se->etype == FLOAT)
printf("Deleted Float is\ %f\n",p->item[p->top].element.fVal);
else if(se->etype == STRING)
printf("Deleted String is\ %s\n",p->item[p->top].element.pVal);


--p->top;
}
return;
}


void display(struct stack *p,struct stackelement *se)
{
int i;
if(p->top == -1)
printf("Stack is Empty\n\n");
else
{
if(se->etype == INT)
{
for(i=p->top; i >= 0; i--)
printf("%d\n", p->item.element.iVal );
}

else if(se->etype == FLOAT)
{
for(i = p->top; i >= 0; i--)
printf("%f\n", p->item.element.fVal);
}

else if(se->etype == STRING)
{
for(i = p->top; i >= 0; i--)
printf("%s\n",p->item[p->top].element.pVal);
}
/*((((*(p)).item)[0]).element).pVal*/
}
return;
}

void menu(struct stack *s,struct stackelement *s_elem)
{
int num=0;
int choice;
int flag=1;

while(flag)
{
printf("Menu");
printf("\n1.Push");
printf("\n2.Pop");
printf("\n3.Display");
printf("\n4.Exit");
printf("\n5.Clear screen\n");
printf("Enter your choice :");
scanfs("%d",&choice);

switch(choice)
{
case 1:
push(s,s_elem);
system("cls");
break;
case 2:
pop(s,s_elem);
break;
case 3:
display(s,s_elem);
break;
case 4:
flag=0;
break;
case 5:
system("cls");
break;
default:
printf("wrong choice\n");
}
}
}



int main(void)
{
int choice_mm ;
struct stackelement se;
struct stack s;
s.top = -1;

for(;;)
{
printf("Choose the type of stack:\n");
printf("1.Integer\n");
printf("2.Float\n");
printf("3.String\n");
printf("4.Exit\n");
scanf_s("%i", &choice_mm);

switch(choice_mm)
{
case 1:
se.etype=INT;
system("cls");
menu(&s,&se);
system("cls");
break;
case 2:
se.etype=FLOAT;
menu(&s,&se);
break;
case 3:
se.etype=STRING;
menu(&s,&se);
break;
case 4:
exit(0);
break;
default:
printf("wrong input");
}
}
return 0;
}
 
U

user923005

Tarique said:
Hello all.I am trying to implement a stack which can store either
integer or float values.
The code is given below:

...snip...

Here is the final code:
Works fine in case of Integer n floats.However i lose track of the
character pointer once i exit the push function (in case of strings).
So in case of *Strings* i cannot display the popped string or the
members of the stack at any given time.
Using an extra global variable to keep track also does not help!
It's confusing!!!

PS:ive not really bothered about scanf..Will change that :)

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define STACKSIZE       100
#define INT             1
#define FLOAT           2
#define STRING          3

struct stackelement{
int etype;      /*etype equals INT,FLOAT,STRING*/
                        /*depending on the type of the */
                        /*corresponding element */
union {
        int     iVal;
        float   fVal;
        char    *pVal;

}element;
};

struct stack{
int top;
struct stackelement item[STACKSIZE];

};

void push(struct stack *p,struct stackelement *se)
{
int     test;
int     iValue  = 0;
float   fValue  = 0.0;
char    cValue[10];

printf("Enter the number/character to push");
if(se->etype == INT)
        scanf("%d",&iValue);
else if(se->etype == FLOAT)
        scanf("%f",&fValue);
else if(se->etype == STRING)
{
        while((test=getchar())!='\n')
                ;
        fgets(cValue,10,stdin);

}

if(p->top == STACKSIZE-1 )
     printf("overflow\n");

else
{
        if(se->etype == INT)
                p->item[++p->top].element.iVal=iValue;
        else if(se->etype == FLOAT)
                p->item[++p->top].element.fVal=fValue;
        else if(se->etype == STRING)
                p->item[++p->top].element.pVal=cValue;

}
return;
}

void pop(struct stack *p,struct stackelement *se)
{
if(p->top==-1)
     printf("underflow\n");
else
{
        if(se->etype == INT)
                printf("Deleted Integer is\ %d\n",p->item[p->top].element.iVal);
        else if(se->etype == FLOAT)
                printf("Deleted Float is\ %f\n",p->item[p->top].element.fVal);
        else if(se->etype == STRING)
                printf("Deleted String is\ %s\n",p->item[p->top].element.pVal);

        --p->top;

}
return;
}

void display(struct stack *p,struct stackelement *se)
{
int i;
if(p->top == -1)
     printf("Stack is Empty\n\n");
else
{
        if(se->etype == INT)
        {
                for(i=p->top; i >= 0; i--)
                        printf("%d\n", p->item.element.iVal );
        }

        else if(se->etype == FLOAT)
        {
                for(i = p->top; i >= 0; i--)
                        printf("%f\n", p->item.element.fVal);
        }

        else if(se->etype == STRING)
        {
                for(i = p->top; i >= 0; i--)
                        printf("%s\n",p->item[p->top].element.pVal);
        }
        /*((((*(p)).item)[0]).element).pVal*/

}
return;
}

void menu(struct stack *s,struct stackelement *s_elem)
{
int num=0;
int             choice;
int             flag=1;

while(flag)
{
        printf("Menu");
        printf("\n1.Push");
        printf("\n2.Pop");
        printf("\n3.Display");
        printf("\n4.Exit");
        printf("\n5.Clear screen\n");
        printf("Enter your choice :");
        scanfs("%d",&choice);

        switch(choice)
        {
            case 1:
                push(s,s_elem);
                system("cls");
                break;
            case 2:
                pop(s,s_elem);
                break;
            case 3:
                display(s,s_elem);
                break;
            case 4:
                flag=0;
                break;
            case 5:
                system("cls");
                break;
            default:
                printf("wrong choice\n");
     }

}
}

int main(void)
{
int     choice_mm ;
struct  stackelement se;
struct  stack s;
s.top = -1;

for(;;)
{
        printf("Choose the type of stack:\n");
        printf("1.Integer\n");
        printf("2.Float\n");
        printf("3.String\n");
        printf("4.Exit\n");
        scanf_s("%i", &choice_mm);

        switch(choice_mm)
        {
                case 1:
                        se.etype=INT;
                        system("cls");
                        menu(&s,&se);
                        system("cls");
                        break;
                case 2:
                        se.etype=FLOAT;
                        menu(&s,&se);
                        break;
                case 3:
                        se.etype=STRING;
                        menu(&s,&se);
                        break;
                case 4:
                        exit(0);
                        break;
                default:
                        printf("wrong input");
        }



}
return 0;
}- Hide quoted text -

- Show quoted text -


/*
This thing still has a long way to go, but it is a little closer to
what you want.
The string you were using was an automatic variable. When a function
exits, all of its automatic variables go away.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define STACKSIZE 100
#define CHAR_ELEMENT_SIZE 10
typedef enum element_type {
uninitialized = 0, integer, floating, string
} e_type;

typedef struct stackelement {
e_type etype;
union {
int iVal;
float fVal;
char pVal[CHAR_ELEMENT_SIZE];
} element;
} ste;

typedef struct stack {
int top;
ste item[STACKSIZE];
} Stack;

void push(struct stack * p, struct stackelement * se)
{
int iValue = 0;
float fValue = 0.0;
char cValue[CHAR_ELEMENT_SIZE]={0};
int converted;
char *collected;

printf("Enter the number/string to push: ");
fflush(stdout);
if (se->etype == integer)
converted = scanf("%d", &iValue); /* Check converted and take
appropiate action! */
else if (se->etype == floating)
converted = scanf("%f", &fValue); /* Check converted and take
appropiate action! */
else if (se->etype == string) {
collected = fgets(cValue, sizeof cValue, stdin); /* Check
collected and take appropiate action! */
}
if (p->top == STACKSIZE - 1)
printf("overflow\n");
else {
if (se->etype == integer)
p->item[++p->top].element.iVal = iValue;
else if (se->etype == floating)
p->item[++p->top].element.fVal = fValue;
else if (se->etype == string)
strcpy(p->item[++p->top].element.pVal , cValue);
else
puts("Unexpected element type.");
}
return;
}

void pop(struct stack * p, struct stackelement * se)
{
if (p->top == -1)
printf("underflow\n");
else {
if (se->etype == integer)
printf("Deleted Integer is %d\n", p->item[p-
top].element.iVal);
else if (se->etype == floating)
printf("Deleted Float is %f\n", p->item[p-
top].element.fVal);
else if (se->etype == string)
printf("Deleted String is %s\n", p->item[p-
top].element.pVal);
--p->top;
}
return;
}

void display(struct stack * p, struct stackelement * se)
{
int i;
if (p->top == -1)
printf("Stack is Empty\n\n");
else {
if (se->etype == integer) {
for (i = p->top; i >= 0; i--)
printf("%d\n", p->item.element.iVal);
} else if (se->etype == floating) {
for (i = p->top; i >= 0; i--)
printf("%f\n", p->item.element.fVal);
} else if (se->etype == string) {
for (i = p->top; i >= 0; i--)
printf("%s\n", p->item[p->top].element.pVal);
}
/* ((((*(p)).item)[0]).element).pVal */
}
return;
}

void menu(struct stack * s, struct stackelement * s_elem)
{
int choice;
int flag = 1;
char *collected;
char st[4];
while (flag) {
printf("Menu");
printf("\n1.Push");
printf("\n2.Pop");
printf("\n3.Display");
printf("\n4.Exit");
printf("\n5.Clear screen\n");
printf("Enter your choice :");
collected = fgets(st, sizeof st, stdin);
choice = atoi(st);
switch (choice) {
case 1:
push(s, s_elem);
#ifdef WIN32
system("cls");
#else
system("clear"); /* Still, not really portable. */
#endif
break;
case 2:
pop(s, s_elem);
break;
case 3:
display(s, s_elem);
break;
case 4:
flag = 0;
break;
case 5:
system("cls");
break;
default:
printf("wrong choice\n");
}
}
}

int main(void)
{
e_type choice_mm;
struct stackelement se = {0};
struct stack s = {0};
int converted;

s.top = -1;
for (;;) {
printf("Choose the type of stack item:\n");
printf("1.Integer\n");
printf("2.Float\n");
printf("3.String\n");
printf("4.Exit\n");
converted = scanf_s("%i", &choice_mm); /* Check converted and
take appropiate action! */
switch (choice_mm) {
case 1:
se.etype = integer;
system("cls");
menu(&s, &se);
system("cls");
break;
case 2:
se.etype = floating;
menu(&s, &se);
break;
case 3:
se.etype = string;
menu(&s, &se);
break;
case 4:
exit(0);
break;
default:
printf("wrong input");
}
}
return 0;
}
 
B

Barry Schwarz

...snip...

Here is the final code:
Works fine in case of Integer n floats.However i lose track of the
character pointer once i exit the push function (in case of strings).
So in case of *Strings* i cannot display the popped string or the
members of the stack at any given time.
Using an extra global variable to keep track also does not help!
It's confusing!!!

Actually it is a very common mistake. When you are attempting to
build a stack of strings, you store your data in various instances of
the member pVal of the union. pVal is a pointer. It holds an address
and not the contents of the string. The address that you store in
this pointer is the address of the array cValue in the function push.
This causes at least two problems:

The first is that cValue is an automatic object. It gets
created when push is entered AND destroyed when push returns. As soon
as push returns, the address you stored in pVal becomes indeterminate
by definition. Any future attempt you make to evaluate this address
causes undefined behavior.

The second is that even if you gave cValue a life span that
survived multiple calls to push, such as declaring it static, it would
only contain the value from the last call to push. This would
eliminate the undefined behavior. But every instance of pVal would be
pointing to the same address. When you go to print the stack
contents, you would be printing the exact same data for every stack
element.

There are methods for solving the problem:

You could change pVal so it was an array the same size as
cValue. Then you could use strcpy to copy the string itself, not its
address, into pVal.

Instead of using a defined array, you could use malloc to
dynamically allocate space for each new string and store the address
of this new memory in pVal.
PS:ive not really bothered about scanf..Will change that :)



#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define STACKSIZE 100
#define INT 1
#define FLOAT 2
#define STRING 3

struct stackelement{
int etype; /*etype equals INT,FLOAT,STRING*/
/*depending on the type of the */
/*corresponding element */
union {
int iVal;
float fVal;
char *pVal;
}element;
};

struct stack{
int top;
struct stackelement item[STACKSIZE];
};

void push(struct stack *p,struct stackelement *se)
{
int test;
int iValue = 0;
float fValue = 0.0;
char cValue[10];

printf("Enter the number/character to push");
if(se->etype == INT)
scanf("%d",&iValue);
else if(se->etype == FLOAT)
scanf("%f",&fValue);
else if(se->etype == STRING)
{
while((test=getchar())!='\n')
;
fgets(cValue,10,stdin);
}


if(p->top == STACKSIZE-1 )

You should make this test prior to asking the user for input.
printf("overflow\n");

else
{
if(se->etype == INT)
p->item[++p->top].element.iVal=iValue;
else if(se->etype == FLOAT)
p->item[++p->top].element.fVal=fValue;
else if(se->etype == STRING)
p->item[++p->top].element.pVal=cValue;
}
return;
}

void pop(struct stack *p,struct stackelement *se)
{
if(p->top==-1)
printf("underflow\n");
else
{
if(se->etype == INT)
printf("Deleted Integer is\ %d\n",p->item[p->top].element.iVal);
else if(se->etype == FLOAT)
printf("Deleted Float is\ %f\n",p->item[p->top].element.fVal);
else if(se->etype == STRING)
printf("Deleted String is\ %s\n",p->item[p->top].element.pVal);


--p->top;
}
return;
}


void display(struct stack *p,struct stackelement *se)
{
int i;
if(p->top == -1)
printf("Stack is Empty\n\n");
else
{
if(se->etype == INT)
{
for(i=p->top; i >= 0; i--)
printf("%d\n", p->item.element.iVal );
}

else if(se->etype == FLOAT)
{
for(i = p->top; i >= 0; i--)
printf("%f\n", p->item.element.fVal);
}

else if(se->etype == STRING)
{
for(i = p->top; i >= 0; i--)
printf("%s\n",p->item[p->top].element.pVal);
}
/*((((*(p)).item)[0]).element).pVal*/
}
return;
}

void menu(struct stack *s,struct stackelement *s_elem)
{
int num=0;
int choice;
int flag=1;

while(flag)
{
printf("Menu");
printf("\n1.Push");
printf("\n2.Pop");
printf("\n3.Display");
printf("\n4.Exit");
printf("\n5.Clear screen\n");
printf("Enter your choice :");
scanfs("%d",&choice);

switch(choice)
{
case 1:
push(s,s_elem);
system("cls");
break;
case 2:
pop(s,s_elem);
break;
case 3:
display(s,s_elem);
break;
case 4:
flag=0;
break;
case 5:
system("cls");
break;
default:
printf("wrong choice\n");
}
}
}



int main(void)
{
int choice_mm ;
struct stackelement se;
struct stack s;
s.top = -1;

for(;;)
{
printf("Choose the type of stack:\n");
printf("1.Integer\n");
printf("2.Float\n");
printf("3.String\n");
printf("4.Exit\n");
scanf_s("%i", &choice_mm);

switch(choice_mm)
{
case 1:
se.etype=INT;
system("cls");
menu(&s,&se);
system("cls");
break;
case 2:
se.etype=FLOAT;
menu(&s,&se);
break;
case 3:
se.etype=STRING;
menu(&s,&se);
break;
case 4:
exit(0);
break;
default:
printf("wrong input");
}
}
return 0;


Do you think your code can ever reach this statement?


Remove del for email
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top