confused with a char array problem

This is a discussion on confused with a char array problem within the C++ Programming forums, part of the General Programming Boards category; Here's the problem
Write a function that will return a pointer to a character, specified by the user of the ...

confused with a char array problem

Here's the problem
Write a function that will return a pointer to a character, specified by the user of the function, within a character array. The array and the desired character are to be the only two inputs to the function.

I am confused with the purpose of the problem. Does it ask for the pointer address or the character? Does there exist more than one data structures?

The "purpose" of the function would be to check a string for a character. Let's say you let a user input a string and you want to see if it has a space in it. How could you use your function to tell you that?

A bunch of problems there. First off, you never declare the use of the std namespace. You shouldn't read a string in with the >> operator. You should use cin.getline(). Secondly, if you had even attempted to compile this, you would have known you're calling your function with the wrong identifier. What the hell is "findchar", you called it "loot_for_char". You also, as I said before, shouldn't use system(), use cin.get() to pause.

Lastly, you can really cut down that function a whole lot by eliminating that temp pointer all together. Consider that your str[val] already points to null if it doesn't point to the correct character.

A bunch of problems there. First off, you never declare the use of the std namespace. You shouldn't read a string in with the >> operator. You should use cin.getline(). Secondly, if you had even attempted to compile this, you would have known you're calling your function with the wrong identifier. What the hell is "findchar", you called it "loot_for_char". You also, as I said before, shouldn't use system(), use cin.get() to pause.

Lastly, you can really cut down that function a whole lot by eliminating that temp pointer all together. Consider that your str[val] already points to null if it doesn't point to the correct character.

Thanks for the comment,but what's difference if using cin.getline()? and replacing system() by cin.get()?
here's a recursive version, any suggestion for this one?