Error switch, help me please!

hi guys, i have a problem whith switch.. help me please.. errors:
- expected unqualified-id before "switch"
- expected `,' or `;' before "switch"

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int errno;
struct dip{
       int matr;
       char cogn[30];
       char nome[30];
       char comune[30];
       int eta;
       char sex[30];
};
struct dip x;

switch(opz){
    case 1:
         
         break;
    case 2:
         
         break;
    case 3:
         
         break;
    case 4:
         
         break;
    case 5:
         
         break;
    default:
            printf("L'OPZIONE INSERITA NON E' DISPONIBILE...RITENTA!\n");
            system("PAUSE");
            break;
}

main(){
    FILE*fp;
    int i,n,opz;
    
    while(1){
        printf("Benvenuto nel menĂ¹!\nOpzioni disponibili:\n");
        printf("1)INSERISCI DATI\n");
        printf("2)RICERCA UTENTE\n");
        printf("3)STAMPA ELENCO UTENTI\n");
        printf("4)ESCI DAL MENU'\n");
        printf("Inserisci l'opzione desiderata: ");
        scanf("%d", &opz);
        
    }
    
    fclose(fp);
    system("PAUSE");
}
Last edited on
I hate to point these simple things out but it seems that your switch statement isn't actually inside a function. Only declarations can go outside functions.
Topic archived. No new replies allowed.