Thread: Very strange problem!

  1. #16
    pwning noobs Zlatko's Avatar
    Join Date
    Jun 2009
    Location
    The Great White North
    Posts
    132
    Quote Originally Posted by Zlatko View Post
    Are you using a microsoft compiler?

    If so, check PRB: "Floating-point Support Not Loaded" Error with scanf()
    Try initializing rt and gt before calling scanf.
    Its crazy, I know.

    Well, don't keep us in suspense!

  2. #17
    Registered User
    Join Date
    Feb 2009
    Posts
    278
    Code:
    if (isalpha(str1[i]))
              {
                   printf("\n%c", str1[i]);
               }
              else 
              {
                   printf("\n%c", str1[i]);
              }
    Isn't this a pointless if statement? Id does the same thing no matter what the result of the condition.

  3. #18
    Registered User
    Join Date
    Jun 2008
    Posts
    11
    Quote Originally Posted by Zlatko View Post
    Are you using a microsoft compiler?

    If so, check PRB: "Floating-point Support Not Loaded" Error with scanf()
    Try initializing rt and gt before calling scanf.
    Its crazy, I know.
    I'm not using a Microsoft Compiler, I'm using MingW, so I suppose the problem is not related to that.

    I've followed $l4xklynx suggestion and used fgets for all inputs. Also read the faq about input at Cprogramming.com FAQ > How do I get a number from the user (C) and decided to use this:

    Code:
    char buf[BUFSIZ];
      float i;
      
      printf ("Enter your number: ");
      
      if (fgets(buf, sizeof(buf), stdin) != NULL)
      {
        i = atof(buf);
        printf ("You entered %f\n", i);
      }
    This is good for what I want and works fine!

    For strings and chars I also used fgets. Thank you all for the kind responses and help.

  4. #19
    Registered User
    Join Date
    Oct 2008
    Posts
    115
    Good to hear it's working fine.. now you can go ahead and refine your code. don't forget to follow the code snippet that I provided to you in the link, that removes the unnecessary character input.
    Last edited by $l4xklynx; 06-26-2009 at 06:37 PM. Reason: additional info

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strange problem with GETLINE
    By wco5002 in forum C++ Programming
    Replies: 13
    Last Post: 07-07-2008, 09:57 AM
  2. Strange problem
    By G4B3 in forum C Programming
    Replies: 6
    Last Post: 05-14-2008, 02:07 PM
  3. Strange problem with classes in header files
    By samGwilliam in forum C++ Programming
    Replies: 2
    Last Post: 02-29-2008, 04:55 AM
  4. Strange problem
    By ~Kyo~ in forum Game Programming
    Replies: 0
    Last Post: 02-14-2006, 10:35 PM