Isn't this a pointless if statement? Id does the same thing no matter what the result of the condition.Code:if (isalpha(str1[i])) { printf("\n%c", str1[i]); } else { printf("\n%c", str1[i]); }
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:
This is good for what I want and works fine!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); }
For strings and chars I also used fgets. Thank you all for the kind responses and help.
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