Hi everyone;
I have a character array of 13 elements and I already defined the first 5 ones. The rest chars are constant so all I need to do is assign the chars between 6-12 instead of writing them one by one.To make it clearer, say my string is "ILoveYouMary" and I already assigned "ILove" part and I need to assign the rest of the array i.e "YouMary" to my char variable at once.
I want to do it in a go, rather than go line by line and
variable[6]='Y';
variable[7]='o';
varialbe[8]='u';
.
.
.
Thank you.Have a good day.
Cheers.
ssmg
0
Newbie Poster
Recommended Answers
Jump to PostI'm not sure there is syntaxically correct way provided by C++ (or C legacy stuff), but here is one slightly dirty way to get it done:
memmove(variable + 6, "YouMary", 7 * sizeof(char));
All 4 Replies
mike_2000_17
2,669
21st Century Viking
Team Colleague
Featured Poster
mrnutty
761
Senior Poster
mrnutty
761
Senior Poster
ssmg
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.