He guys, just took a look at my little codefragment
text[5]=' '; text[6]='k'; text[7]='g';
How to put this in one single line? for example
//This does'nt works! text[5 to 7]=" kg";
Sorry for this stupid question, i guess there is a solution, but i was interrested in another idea than mine :-)
Of course it doesn't - what gave you the idea that it might?
Programming languages are not like "natural" language - a compiler will not try to think what you mean.
Programming languages have strictly & precisely defined syntax - you need to learn that syntax, and stick to it!
It sounds like you need to get yourself a 'C' textbook, and spend some time learning the 'C' programming language.
"How to put this in one single line?"
One line would be:
One statement would be:
(text[5]=' ', text[6]='k', text[7]='g');
Hello Andy, thanks for your answer, but the blame on me. Yes your are right, i should spend some more time with a 'C' text book. I wrote this rubish
to give someone just an idea, what i'am looking for.
Now i explored
strcpy(&text[5]," kg");
Seemed to work well. Just a hint to other users, a chr$(0) is appended after the "g". So take another look to be sure that you have declared the string long enough.
Hello Dan, thanks for your code
Just a question of principles: What is better, this or strcpy? Where are differences?
"What is better, this or strcpy? Where are differences?"
What are your requirements regarding the NUL-terminator?
strcpy() copies its second argument including the argument string's NUL-terminator.
If that's not what you want, then use strncpy() with the third argument chosen to avoid copying the NUL-terminator or assign characters to individual string (array) elements.