This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

String strang strung

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 :-)

Parents
  • //This does'nt works!
             text[5 to 7]=" kg";
    


    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.

Reply
  • //This does'nt works!
             text[5 to 7]=" kg";
    


    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.

Children
  • 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

    //This does'nt works!
             text[5 to 7]=" kg";
    


    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.