
I am having troubles with the switch()
Quote:
> Can some one help, me. Because I keep having errors!
> #include <stdio.h>
> #include <stdlib.h>
> int main()
> {
> int z(char[]);
Trash the line above.
Quote:
> void push(double);
> double pop(void);
Move these to outside main. Function prototypes inside a function is
nowadays obsolete. BTW, there doesn't seem to be implementation code for
either function.
Quote:
> {
The curly above is unnecessary.
Quote:
> int type;
> char s[];
These variables should have been declared in the beginning of main and s
should have been given a size if it's declared as an array. Try char
s[10], for example.
Quote:
> while((type=2(s))!=EOF)
The line above is in error. Probably you meant something like:
while ((type = getchar()) != EOF)
Quote:
> {
> switch(type);
Trash the line above and put in the following:
switch (type)
{
Quote:
> case 'q':
> printf("Quit");
You should read something into s before using it. For example,
fgets(s, sizeof(s), stdin);
Quote:
> push(atof(s));
Remember to write the push function...
Quote:
> break;
> case 'e':
> printf("Enter a string");
> push pop(), e pop();
What in earth do you attempt to achieve here??? If you want to read a
string, use fgets and get rid of the push-pop line.
Quote:
> break;
> case 'd':
> printf("Delete all strings");
> push pop(), d pop());
Hmm... I'm beginning to wonder if this is a troll... The above line
should be recycled.
Quote:
> break;
> case 'a':
> printf("Show all strings");
> push(pop(), a pop());
Same here...
Quote:
> break;
> default:
> printf("Have a nice day");
> break;
> }
> }
> return 0;
Nice to see a return code from main :)
Quote:
> }
What should this program do, anyway?
AriL
--
Humans may send email (if absolutely necessary) to the
obvious non-spam address.