i am trying to get my program to read a SPACE, so i can validate a postcode. this is the code below but wont read the space properly.
can anyone help?
Code:bool isValidPostcode(char postcode[]) { int errorcounter = 0; int spaceCheck = 0; if(isalpha(post1[0])) { cout << "this is correct" <<endl; } else { cout << "this is incorrect"<<endl; errorcounter++; } if(isalpha(post1[1])) { cout << "this is correct"<<endl; } else { cout << "this is incorrect"<<endl; errorcounter++; } if(isdigit(post1[2])) { cout << "this is correct"<<endl; } else { cout << "this is incorrect"<<endl; errorcounter++; } spaceCheck = ((int)post1[3]); spaceCheck = 0; if (spaceCheck == 32) { cout <<"this is correct" <<endl; } else { cout <<"this is incorrect" <<endl; errorcounter++; } // no space so check remainding 3 chars if (isdigit(post1[4])) { cout << "this is correct" <<endl; } else { cout << "this is correct"<<endl; errorcounter++; } if (isalpha(post1[5])) { cout << "this is incorrect" <<endl; } else { cout << "this is correct" <<endl; errorcounter++; } if (isalpha(post1[6])) { cout << "this is incorrect" <<endl; } else { cout << "this is correct" <<endl; errorcounter++; } if (errorcounter ==0) { cout << "the post code it VALID"; return true; } else { cout <<"the postcode is INVALID please enter in again"; return false;