answersLogoWhite

0

#include <iostream>

#include <string>

using std::string;

using std::cin;

using std::cout;

using std::endl;

using std::getline;

int main()

{

string myString = "";

cout << "Enter a string: ";

getline(cin, myString);

char mySymbol = 'a';

cout << "Enter a symbol to search for: ";

mySymbol = getchar();

bool symbolFound = false;

for (int index = 0; index < myString.length(); index++)

{

if (mySymbol false)

{

cout << "The symbol " << mySymbol << " was not found!";

}

cin.get();

cin.get();

return 0;

}

User Avatar

Wiki User

12y ago

What else can I help you with?

Continue Learning about Engineering

How do you convert a string into a character array?

A string is, by definition, a character array. No conversion is required.


How do you write a c program for to replace a character of string either fro mbeginning or ending or at specified location?

The standard C library includes two simple utilities to find the first or last occurance of a given character within a given string, strchr() to search from the start and strrchr() for the reverse start from the end. Subject to the chosen search direction, you could use one of these two simple API. Both return a pointer to the location of the matching character within the string, or NULL if no such character is found. Note that this approach assumes a mutable string, a string stored in writeable memory. A string literal is a constant string and not generally mutable (even though some compilers are very casual about this). That is, strchr("the quick brown fox", 'q') will return a pointer to the first 'q', but since the string is a string of constant characters, you shouldn't use the pointer to change the letter found. To search and modify, you'd use string of variable characters, such as one allocated with the malloc() or strdup() standard API, or one created as a char array.


A character array terminated with the null character is most correctly called what?

zero-terminated string


Is special symbols are valid as a string in java?

Yes. Any special character inside the String is considered as part of the string variable and would not be treated as a special character. Ex: String str = "ABC_$4"; is a valid string declaration


What character terminates all character array strings?

the character string is terminated by '\0'

Related Questions

Difference between character and string?

A string ends with a '\0' character,but character is not.


Which character in string is used to end the string?

Character zero (the byte with the decimal value zero) is sometimes used to end a string. But in other cases, the size of the string is stored at the beginning of the string, and there is no end-of-string character. This allows any character to be included in the string.


How do you convert a character into a string?

A string is, by definition, a character array. No conversion is required.


How do you convert a string into a character array?

A string is, by definition, a character array. No conversion is required.


What is the result of a search for the string?

It seems that your question is incomplete, as it doesn't specify the string you want to search for. The result of a search for a specific string will depend on the context, such as the database or platform being searched, and the string itself. If you provide more details about the string and the search environment, I can give a more precise answer.


Is string an object?

No. A string is, by definition, a character array.


Is string is an object?

No. A string is, by definition, a character array.


How do you write a c program for to replace a character of string either fro mbeginning or ending or at specified location?

The standard C library includes two simple utilities to find the first or last occurance of a given character within a given string, strchr() to search from the start and strrchr() for the reverse start from the end. Subject to the chosen search direction, you could use one of these two simple API. Both return a pointer to the location of the matching character within the string, or NULL if no such character is found. Note that this approach assumes a mutable string, a string stored in writeable memory. A string literal is a constant string and not generally mutable (even though some compilers are very casual about this). That is, strchr("the quick brown fox", 'q') will return a pointer to the first 'q', but since the string is a string of constant characters, you shouldn't use the pointer to change the letter found. To search and modify, you'd use string of variable characters, such as one allocated with the malloc() or strdup() standard API, or one created as a char array.


How is data inputted into the tv?

how is data inputted into the tv digital


What is the difference between A and A in string?

Well, A is an identifier; 'A' is a character-literal; "A" is a string literal (of 1 character); "'A'" is another string literal (of 3 characters).


A character array terminated with the null character is most correctly called what?

zero-terminated string


How is data inputted into the phone technology?

how is data inputted intocellphone technology