How to add additional character in multiple places of an array string
-
Hii I am a beginner of C++ programming environment. My question: Suppose there is a array..and the contents of the array="ironman" Now, i need to insert some additional character to this string like "i*r%o#n@m^a!n" Also i need to reversely generate the original contents. That means from "i*r%o#n@m^a!n" to "ironman".. Also i have one constraint, i cannot use much of library function..i can use loop only. Thanks in Advance !!
-
Hii I am a beginner of C++ programming environment. My question: Suppose there is a array..and the contents of the array="ironman" Now, i need to insert some additional character to this string like "i*r%o#n@m^a!n" Also i need to reversely generate the original contents. That means from "i*r%o#n@m^a!n" to "ironman".. Also i have one constraint, i cannot use much of library function..i can use loop only. Thanks in Advance !!
What have you tried?
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
-
Hii I am a beginner of C++ programming environment. My question: Suppose there is a array..and the contents of the array="ironman" Now, i need to insert some additional character to this string like "i*r%o#n@m^a!n" Also i need to reversely generate the original contents. That means from "i*r%o#n@m^a!n" to "ironman".. Also i have one constraint, i cannot use much of library function..i can use loop only. Thanks in Advance !!
-
Hii I am a beginner of C++ programming environment. My question: Suppose there is a array..and the contents of the array="ironman" Now, i need to insert some additional character to this string like "i*r%o#n@m^a!n" Also i need to reversely generate the original contents. That means from "i*r%o#n@m^a!n" to "ironman".. Also i have one constraint, i cannot use much of library function..i can use loop only. Thanks in Advance !!
Well, it doesn't look a daunting task, however you have to allocate a new array having the double size of the original one. Then you could copy the original items
o[i]
into new onesn[2*i]
, finally add the 'additional characters at odd indices. The inverse operation, is, well, inverse, namelyn[2*i] -> o[i]
.