find function

How do I find (find function) a unique character in a string that is read in from a file, without knowing what the unique character is? So, if another string is read in with a different unique character, it will still work.
closed account (iw7Gy60M)
Do you mean you want to figure out which character or characters appear only once in a given string?
Huh? You can't search for a character if you don't know what the character is.

You could pass the character in to your program through the command line.

1
2
3
4
int main (int argc, char * argv[])
{  char unique_char = argv[1][0];  //  First character of first argument
 ...
}

a unique character in a string

I don't think that "find" is the usual term term for what you want.

Nevertheless, you could first solve a different problem. Given a string, count how many times each character in it repeats.

Example:
Input: "banana"
Output: {{a, 3}, {b, 1}, {n, 2}}
Topic archived. No new replies allowed.