I am having troubles with the switch() 
Author Message
 I am having troubles with the switch()

Can some one help, me. Because I keep having errors!

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

int main()
{
 int z(char[]);
 void push(double);
 double pop(void);
 {
  int type;
  char s[];
  while((type=2(s))!=EOF)
   {
     switch(type);
     case 'q':
        printf("Quit");
        push(atof(s));
        break;
           case 'e':
        printf("Enter a string");
        push pop(), e pop();
        break;
           case 'd':
        printf("Delete all strings");
        push pop(), d pop());
        break;
           case 'a':
        printf("Show all strings");
        push(pop(), a pop());
        break;
           default:
        printf("Have a nice day");
        break;
   }
 }

return 0;

Quote:
}



Mon, 23 Jul 2001 03:00:00 GMT  
 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.



Mon, 23 Jul 2001 03:00:00 GMT  
 I am having troubles with the switch()
Groovy hepcat Serge Dardenne was jivin' on Thu, 4 Feb 1999 02:33:17
-0500 in comp.lang.c.
I am having troubles with the switch()'s a cool scene! Dig it!

Quote:
>     switch(type);
>     case 'q':

  Here's the trouble. Try

    switch(type)
    {
      case 'q':
        /* etc. */
    }
--

----- Dig the EVEN NEWER, MORE IMPROVED news sig!! -----

-------------- Shaggy was here! ---------------
    http://aardvark.apana.org.au/~phaywood/
============= Ain't I'm a dawg!! ==============



Mon, 23 Jul 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. i am unable to read from a file having 26ascii character(ctrl+z)

2. I am having with my bishop

3. HELP, I am having problems with pointer...

4. I am having probability d

5. I am having probability difficulties...HELP

6. I am having problems setting up that a specified dialog is displayed before any others

7. I am having problems with MFC42.dll file

8. How to switch between having an App WITH Menu and one without

9. Having trouble converting from VC++ v6.0 to VC.NET

10. Having trouble with Events/Delegates

11. having some trouble directories

12. Having trouble with time_t

 

 
Powered by phpBB® Forum Software