![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Programming A discussion forum for programs and programming used in tech-related businesses. |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Just passing by.
|
getchar() in C on Unix
Hi, I'm trying to write a portion of a program that outputs error when characters other than A, B and S are inputted with the use of getchar() then end, except I can't get it to work. Currently it looks like this:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main( void ) {
int ch;
printf( "Input characters:\n" );
while ( ch != '\n' ) {
ch = getchar();
if( ch != 'A' || ch != 'B' || ch != 'S' ) {
printf( "\nError: Please only input A, B and S.\n" );
return 0;
}
}
return 0;
}
|
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
![]() |
| Thread Tools | |
|
|