answersLogoWhite

0

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.

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

Define program relocation?

program relocation is the process which modifies the object program so that it can be loaded at an address different from the location originally specified.


Which function changes the specified directory?

The function that changes the specified directory is typically chdir() in many programming languages, such as Python and C. In Python, you can use os.chdir(path) to change the current working directory to the specified path. This allows the program to access files and directories relative to the new location.


When coordinates going into a program are specified relative to the program zero point it is called?

rapid


Write an applet program to insert a text at a specified position?

bbbdb


What program searches documents for specified keywords?

search engine


Is it possible to make a program which can go to any website and click on specified topics?

Yes.


What is program visible register?

the registers that are used during programming and are specified directly by the instructions.


How can you install a licensed program twice?

Install the program to a different location.


What show does Teto and Miku come from?

The character Teto comes from the program known as UTAU. The character Miku comes from the program known as Vocaloid.


What the definition of program?

a plan of action to accomplish a specified end. a radio or television performence or production


What kind of character is Bubbles on an HBO program?

Bubbles is a prevalent character in the HBO program The Wire. His character is a recovering Heroin addict. His real name is actually Reginald Cousins and has a son that lives with his mother.


Write a program to enter a character and it will tell the character etered?

{char a;...cout > a;cout