home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / os / os2 / programm / 4331 < prev    next >
Encoding:
Text File  |  1992-08-19  |  2.4 KB  |  76 lines

  1. Newsgroups: comp.os.os2.programmer
  2. Path: sparky!uunet!kithrup!stanford.edu!ames!elroy.jpl.nasa.gov!usc!sol.ctr.columbia.edu!The-Star.honeywell.com!umn.edu!orstnews!ucs.orst.edu!hilmera
  3. From: hilmera@ucs.orst.edu (Andrew Hilmer)
  4. Subject: Question and problem with GCC/2
  5. Message-ID: <1992Aug19.212328.15304@talon.ucs.orst.edu>
  6. Sender: usenet@talon.ucs.orst.edu (Usenet News admin)
  7. Nntp-Posting-Host: ucs.orst.edu
  8. Organization: University Computing Services - OSU
  9. Date: Wed, 19 Aug 1992 21:23:28 GMT
  10. Lines: 64
  11.  
  12. Compiler: gcc/2 2.1
  13. Problem: problem and question about gcc/2
  14.  
  15. First the question. I have no trouble compiling and linking the
  16. sample1.c "hello world" program, but I am curious about the multiple
  17. prompts that link386 gave me. I just hit <enter> and the defaults
  18. seemed to work ok. I could find no on-line documentation of link386,
  19. of course. Is there some documentation of link386 available on the
  20. net? I am FLAT broke, so getting a shelf-full of IBM docs is not an
  21. option.
  22.  
  23. Now the problem. While the sample1.c file worked fine, a simple
  24. programming assignment performed bizarrely after compiled and linked.
  25.  
  26. 88888888888888888888888888888888888888888888888888888888
  27.  
  28. /*
  29.   This program takes the input of two numbers, one
  30.   integer, one floating point, and prints them back out.
  31. */
  32.  
  33. #include <stdio.h>
  34.  
  35. main()
  36. {
  37.   int x;
  38.   float y;
  39.  
  40. /*  fflush(stdin); */
  41.   printf("This is my first C program.\n");
  42.   printf("Enter an integer: ");
  43.   scanf("%d", &x);
  44.   printf("Enter a floating point number: ");
  45.   scanf("%f", &y);
  46.   printf("The value stored in x is %d\n", x);
  47.   printf("The value stored in y is %f\n", y);
  48. }
  49.  
  50. 88888888888888888888888888888888888888888888888888888888
  51.  
  52. When run, it prints nothing but a line or two and a blinking cursor.
  53. As a shot in the dark, I entered 3, hit enter (got another big
  54. nothing), then entered 93.9 and hit enter.
  55.  
  56. It printed:
  57.  
  58. This is my first C program.
  59. Enter an integer: Enter a floating point number: The value stored in x is 3
  60. The value stored in y is 93.900002
  61.  
  62. WHY the F**K does it do what is supposed to be executed FIRST, LAST????.
  63. It worked fine with EMX/GCC, GCC for Unix, and I didn't have to do
  64. anything fundamental to get it work with Think C on the mac. Hell, I
  65. basically just typed in what the teacher said to type in.
  66.  
  67. Don't worry, I used EMX for the class. But now that I have a lot of
  68. time on my hands, I want to track this strangeness down.
  69.  
  70. Thanks
  71.  
  72. andy
  73. -- 
  74. hilmera@ucs.orst.edu  Why settle for the *lesser* of evils? Cthulu 92!
  75.  
  76.