cin problem

Hi all!

I've got a little problem:

this is my code:

int m;
...
case 8:
cout<<"\nVuoi calcolare a chi appartiene il minimo o il massimo voto di una verifica? (MIN=0, MAX=1): ";
cin>>m; <<-- THIS IS THE PROBLEM if i comment this line the program works until this line otherwise not!

/*cout<<"\n mm = "<<mm;

cout << "Di che verifica (1 - " << VERIFICHE << ")?: ";
cin >> i;
i = i-1;

cout<<"\n Verifica scelta: "<<i;

if(mm == 0){
minni = allievo[0][i].voto; // OKKIO!!! Il primo allievo deve aver svolto la verifica
for(j=0;j<STUDENTI;j++){
if((allievo[j][i].voto > 0) && (allievo[j][i].voto < minni)){ // se voto presente e minore del minimo
minni = allievo[j][i].voto; // l'attuale e' il nuovo minimo
k = j;
cout<<"\nNuovo MINIMO: "<<minni<<" di allievo: "<<allievo[k][i].voto;
}
}
cout << "Il minimo voto nella verifica " << i+1 << " vale: "<< minni << " e appartiene a " << allievo[k][i].nome << endl;
}

if(mm == 1){
macsi = allievo[0][i].voto; // OKKIO!!! Il primo allievo deve aver svolto la verifica
for(j=0;j<STUDENTI;j++){
if(allievo[j][i].voto > macsi){ // se voto maggiore del massimo
macsi = allievo[j][i].voto; // l'attuale e' il nuovo minimo
k = j;
cout<<"\nNuovo MASSIMO: "<<minni<<" di allievo: "<<allievo[k][i].voto;
}
}
cout << "Il massimo voto nella verifica " << i+1 << " vale: " << k << " e appartiene a " << allievo[k][i].nome << endl;
}*/
break;
My guess is that you aren't declaring your usage of std::cin. What is the error that you are getting?
The program starts but don't show nothing:BLANK SCREEN.
Can you help me?
Can you show what comes before case 8 - there might be something left behind in the buffer ... and please use code-tags
http://ideone.com/l4bYiw

here you can find the complete code.

i think that is a devc++ problem because on ideone.com works!
I didn't try to run the program However it gave two compiler warnings.
53	16	[Warning] unused variable 'n' [-Wunused-variable]
60	19	[Warning] array subscript is above array bounds [-Warray-bounds]

The first doesn't matter.

But an out-of-bounds array access is a serious error. You should check your use of subscripts at line 60 before going any further.

change
 
   for(j=0;j<=VERIFICHE;j++)
to
 
    for(j=0;j<VERIFICHE;j++)

Also add the compiler options in DevC++
 
-std=c++11 -Wextra  -Wall -pedantic

in order to generate proper warning/error messages.




Last edited on
It does NOT work on ideone, you can see the output of the runtime error at the bottom of the page you linked to. After changing "CLS" to "clear" and deleting "PAUSE" you have a functional program though.
Last edited on
Topic archived. No new replies allowed.