WHY DOESN"T THIS WORK, GRRRR !@!@!@!@
the project ask the user to enter a string and then prompts the user to enter a character. the program should display the location of the first occurrence of the character in the string.
for example: the user enters the string "abcde", and the character "d", the program should say the character d is character number 4 in the string.
can nebody help me out on this, i would greatly appreciate it =0)Code:#include <iostream.h> #include <iomanip.h> int main() { char line[50]; char * ch_ptr; char oneChar; int count = 0; cout << "\nEnter a string of characters:\n\n"; cin.getline(line, 50); cout << "\nEnter one character in the previous string\n"; cin >> oneChar; for (ch_ptr = line; *ch_ptr == ' '; ++ch_ptr); while (*ch_ptr != '\0') { ++count; if ((ch_ptr == oneChar) && (*ch_ptr != ' ')) { cout << "\nThe string you entered is in the " << count << " space .\n\n"; } else (*ch_ptr != oneChar) { cout << "\nYou have entered the wrong character"; } } return 0; }