[ back to toc ]

code won't read 'gets' after first time.

Date: 2002/03/16 18:49

Q:
I know it is really scattered, but i only jst started to learn C. and this
is a University Assignment so dont be confused about the subject of the
coding.
i'm using Dev C/C++ for windows 98. my prgoram wont read the 'gets' input
when the program is repeated.

#include <stdlib.h>
#include <windows.h>
#include <string.h>
#include <math.h>

float day, month, year, hour, minute, second, result, luckyno;
int monthi, resulti;
char name[40];
char *montharray[12] = { "Janruary" , "February", "March", "April", "May",
"June", "July", "August", "September", "October", "November",
"December" };
char *luckyarray[27] = { "A" , "B" , "C" , "D" , "E" , "F" , "G" , "H" ,
"I" , "J" , "K" , "L" , "M" , "N" , "O" , "P" , "Q" , "R" , "S" , "T" ,
"U" , "V" , "W" , "X" , "Y" , "Z" };

void getname ()
{
printf("\n");
printf("Please Enter the Person's Name: \n");
gets(name);
printf("\n");

}

void information()
{
printf("\n");
printf("Please Enter the Hour(hh): ");
scanf(" %f", &hour);
printf("\n");
printf("Please Enter the Minute(mm): ");
scanf(" %f", &minute);
printf("\n");
printf("Please Enter the Second(ss): ");
scanf(" %f", &second);
printf("\n");
printf("Please Enter the Day(dd): ");
scanf(" %f", &day);
printf("\n");
printf("Please Enter the Month(mm): ");
scanf(" %f", &month);
printf("\n");
printf("Please Enter the Year(yy): ");
scanf(" %f", &year);
printf("\n");
monthi = month - 1;

}

void calc(){

result = (day * 100000000) + (month * 1000000) + (year * 10000) + (hour
* 100) + (minute);
result = result + (second / 100);
result = result / 3.14;
result = sqrt (result);
result = result * 10;
luckyno = result;
for( ; result > 1 ; ) {
result = result - 1;
}
result = result * 10;
resulti = result;
system("CLS");
}

void printticket()

{

printf
("************************************************************************
*****\n");
printf ("*\n");
printf ("*______________ _-_ BEST OF
BOTH WORLDS \n");
printf ("*\n");
printf ("* \\__(--------/_-_ ____.---'---'---.____ XXIV
INTERNATIONAL CONFERENCE \n");
printf ("*\n");
printf ("* \\_ \\ \\----._________.----/ VENUE: Sydney
Entertainment Centre\n");
printf ("*\n");
printf ("* \\ \\ / / '-_-' DATE: %2.0f, %s,
200%1.0f\n", day, montharray[monthi], year);
printf ("*\n");
printf ("* __,--'.'-'..'-_
\n");
printf ("*\n");
printf ("* /____ || TICKET HOLDER:
%s\n", name);
printf ("*\n");
printf ("* '--.____.-' LUCKY DOOR PRIZE #:
%7.0f%s\n", luckyno, luckyarray[resulti]);
printf ("*\n");
printf
("************************************************************************
*****\n");
printf ("\n");

}

int main(){
start:
getname();
information();
getname();
calc();
printticket();
system("PAUSE");
if(MessageBox(0, "Do You Wish to Enter More Names?", "Ticket Master",
MB_YESNO || MB_ICONQUESTION) == IDOK)

{ system("CLS");

goto start;

}
else
{
system("EXIT");
}
return 0;
}

Thanks
A:
"Change the

MB_YESNO || MB_ICONQUESTION

to

MB_YESNO | MB_ICONQUESTION"

I have seen your comment on the rating: think it over again. I am sure. I
have 19 years of C programming experience. It does not mean that I never
make a mistake, but gives a high probability that I know it better. Just
think it over again regarding the | and the ||.

Bye
Peter

[ back to toc ]