answersLogoWhite

0

char *string = "this is a test";

char *p;

for (p=string; *p!='\0'; p++) if (*p==' ') *p='-';

User Avatar

Wiki User

15y ago

What else can I help you with?

Continue Learning about Engineering

Replace a character by another character in a given string?

C SolutionTo replace a single, specified character with another in a given string, one possibility is ...char *pszString; /* pointer to string */int offset; /* offset of desired character */... initialize pszString and offset*(pszString+offset) = 'A'; /* or whatever new value you want */Obviously, this is a simple example, and it does not consider if offset is greater than the size of the array.If you want to replace every occurence of a character with another, here is another possibility, one that also handles string length ...char *pszString; /* pointer to string */char* pszTemp; /* temporary scanning pointer */char cOldChar; /* character to change */char cNewChar; /* new character */... initialize pszString, cOldChar, and cNewCharfor (pszTemp = pszString; *pszTemp != '\0'; pszTemp++) { /* scan */if (*pszTemp == cOldChar) *pszTemp = cNewChar; /* conditionally replace */}Java Solution// Replace all 'e' characters with 'i' characters in String strstr.replaceAll("e", "i");


What does Emerson compare an iron string to?

"Trust thyself; every heart vibrates to that iron string." Iron string = belief in ones own thoughts, to be self confident.


How do you uppercase letters in palindrome string?

Use toupper from ctype.h for every letter. Obviously, it doesn't matter if the string is palindrom or not.


Which programming language uses a string of 1s and 0s?

You, as a programmer, can use a string with 1s and and 0s (or any other content) in each and every programming language.


What is pallendrome in java?

palindrome in every language means same. it means on reversing a number or string, if we get the same number or string as the case may be ,then the number or string is called palindrome. eg: 1221,111,252 or LIRIL,MADAM etc .

Related Questions

What is the definition find and replace for microsoft word?

Find and Replace are actually two separate items in Microsoft Word. Find does just that, it finds any string of characters you type in. This is very helpful, especially with a large document.Replace will also find the next instance of any string of characters you type into the search box and will replace that string with the string you define. Using Replace, you have two options, you can find the next instance and decide whether or not you want to replace that string, or you can click on the "Replace All" radio button to replace every instance of that string.Care must be taken if you use the "Replace All" option. For instance, if you want to replace the string "the" with "a", words such as "other" will become "oar". Obviously not what you want. "Replace All" works well when having to replace names in a document. All instances of that name can be changed in one click.


Does every string instrument have a bridge?

Yes


Replace a character by another character in a given string?

C SolutionTo replace a single, specified character with another in a given string, one possibility is ...char *pszString; /* pointer to string */int offset; /* offset of desired character */... initialize pszString and offset*(pszString+offset) = 'A'; /* or whatever new value you want */Obviously, this is a simple example, and it does not consider if offset is greater than the size of the array.If you want to replace every occurence of a character with another, here is another possibility, one that also handles string length ...char *pszString; /* pointer to string */char* pszTemp; /* temporary scanning pointer */char cOldChar; /* character to change */char cNewChar; /* new character */... initialize pszString, cOldChar, and cNewCharfor (pszTemp = pszString; *pszTemp != '\0'; pszTemp++) { /* scan */if (*pszTemp == cOldChar) *pszTemp = cNewChar; /* conditionally replace */}Java Solution// Replace all 'e' characters with 'i' characters in String strstr.replaceAll("e", "i");


What is string theroy?

the smallest thing in the universe. also its a vibrating string that creates energy. every thing is related though string theory.


What does Emerson compare an iron string to?

"Trust thyself; every heart vibrates to that iron string." Iron string = belief in ones own thoughts, to be self confident.


How do you uppercase letters in palindrome string?

Use toupper from ctype.h for every letter. Obviously, it doesn't matter if the string is palindrom or not.


If the bit string 0111101111101111110 is bit stuffed what is the output string?

the idea of bit stuffing is to replace every two 1's with 110 (redundancy) !! thats because .. to avoid having a 0111 in the middle of the data !! as 0111 is a delimator !! those , we will get (0111) 01101100110110101101101100 (0111) where (0111) is the start and end delimator !!


How often should you replace your timing belt?

Depends on the year of you Accord. 1976-89 Replace every 60,000 miles 1990-96 Replace every 90,000 miles 1997-10 Replace every 110,000 miles. Replace every 10 years no matter the mileage.


Why do you need a terminating null character at the end of the every string in C programming?

Because the null character represents the end of the string.


How do you finger for a bass guitar?

to finger a bass guitar, you rest your thumb on one of the pickups and pluck with your fingers. that is for the E string if you play on the A String you move your thumb down to the E string and play every time you p;ay on a string, your thumb will be on the string above it.


Does a Dodge Charger 2006 35 V 6 have a timing belt or chain?

Belt, replace every 100,000 miles.Belt, replace every 100,000 miles.


How long is every string in the universe?

Twice as long as its half-way mark.