I am trying to add numbers to a string.
the user is given a choice of either 'a' for adding or 'w' to delete last number entered.
ex: the user types a 500, a 700, a 444
I want to print the string like that 500 ==> 700 ==>444
and if the user type w then when i print the string I get 500==>700
The user type w again then when i print I get 500 only
Here is my program so far but it is giving me errors when compiling something about strings and int and char not being compatible....
need help.....what's wrong with my code??
Code:#include <stdio.h> #include <string.h> #include <stdlib.h> int main(void) { char line; int stack[100]; for(;;) { printf("%s\n","Type 'a' to push followed by number"); printf("%s\n","Type 'r' to pop number"); fgets(line,sizeof(line),stdin); if (feof(stdin)) break; if(line[0]=='a') strcat(stack,line); strcat(stack,"==>"); } printf("%s",stack); return 0; }