Subj : Re: Random Integer Solutions...Help Please... To : borland.public.cpp.borlandcpp From : Ed Mulroy [TeamB] Date : Sun Jun 27 2004 11:11 pm > Hey Ed, I did a little revisions on my program. It seems > that it doesn't like sscanf so... I likes sscanf just find. However what you show does not use it. Your program logic has problems. > #include > ===main returns int. yes, years ago a return value type of int=== ===was assumed. this is not years ago. put in the return type=== > main() > { > int a; > char buffer[133]; > > printf("Input the number of integers you will input,\nand I > will tell you the smallest of the group: "); ===you kept the scanf below=== > scanf("%d", &a); > ===you added the fgets below which is part of the replacement === ===for scanf, but instead of sscanf you followed it with scanf=== ===and as mentioned above, you kept the code which it is=== ===supposed to replace=== ===the scanf line below should be sscanf(buffer, "%d", &a);=== > fgets(buffer, sizeof(buffer), stdin); > scanf("%d", &a); > ===this loop does nothing because the semicolon which follows=== ===the ending parentheses is an empty executable statement=== ===that does nothing 'a' times=== ===it should read in a number and test if it is the smallest=== ===in each pass through the loop=== > for ( ;a > 0; --a); > ===it can't print the smallest number because 1-you have not=== ===read the numbers in or calculated the smallest and=== ===2-because it gives the address of a character string=== ===to printf as if it were a number=== > printf("The smallest number is %d\n", &buffer); > > getchar(); > printf("Press enter..."); > getchar(); > > return 0; > } This is obviously a school thing. I am happy to help cure problems or suggest things but will not do an assignment or test for you. Show what you come up with from this and I will enjoy trying to help. .. Ed > Jeremy Pham wrote in message > news:40df4e3f$1@newsgroups.borland.com... .