Salve ragazzi, scusate l'assenza ma sono stato impegnato. Comunque ho risolto tutti i problemi con c::b.
Adesso ho un problema riguardo un file sorgente che è questo:
il problema è che il terminale, quando inserisco -1 oppure <ctrl-z> (io uso windows 7), invece di terminare la funzione while e eseguire le istruzioni printf successive, dice per -1, di inserire un carattere nuovo valido (come ho scritto in default), mentre per <ctrl-z> dice di inserire un nuovo carattere valido per ogni code, però dovrebbe passare alle funzioni printf dopo il while!. Dove è il problema? Lo stesso problema me lo da anche con l'esercizio rappresentativo del Deitelcodice:#include<stdio.h> main() { int product; float price1=2.98, price2=4.50, price3=9.98, price5=6.67, price4=4.49; float tot1=0, tot2=0, tot3=0, tot4=0, tot5=0; printf("Enter the code of sale products\n"); printf("Enter the EOF to end the input\n"); while((product = getchar() ) != EOF) { switch(product) { case '1': tot1=tot1+price1; break; case '2': tot2=tot2+price2; break; case '3': tot3=tot3+price3; break; case '4': tot4=tot4+price4; break; case '5': tot5=tot5+price5; break; case '\n': case ' ': break; default: printf("Incorrect code number product entered\n"); printf("Enter a new code number\n"); break; } } printf("\n Total earning for each product sale:"); printf("Total product1 %.2f\n", tot1); printf("Total product2 %.2f\n", tot2); printf("Total product3 %.2f\n", tot3); printf("Total product4 %.2f\n", tot4); printf("Total product5 %.2f\n", tot5); return 0; }

Rispondi quotando