CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

How to push the first value to the end of the string

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
janet



Joined: 17 Feb 2004
Posts: 23

View user's profile Send private message

How to push the first value to the end of the string
PostPosted: Tue Mar 16, 2004 1:32 am     Reply with quote

let's say

Code:

BYTE random_value;
BYTE random_string[10];
BYTE data_string[] = "";

for (i = 0; i < 10; i++) {
    random_value = rand();
    sprintf(random_string, "%u", random_value);
    strcat(data_string, random_string);
next;


every new data will be appended at the end of the string.
the string will contain "random_value0 random_value1 random_value2 ..."

What if i want to reverse the order of value in the string so that new value will be appended at the BEGINNING of the string?

the end result i want to get is "random_value9 random_value8 random_value7 ... random_value0"

Cheers
bonev_st



Joined: 16 Mar 2004
Posts: 1
Location: Bulgaria

View user's profile Send private message

PostPosted: Tue Mar 16, 2004 1:51 am     Reply with quote

It can be in this way

BYTE random_value;
BYTE random_string[10];
BYTE data_string[] = "";
int8 i; // must be signed

for (i = 10; i >= 0; i--) {
random_value = rand();
sprintf(random_string, "%u", random_value);
strcat(data_string, random_string);
next;

Wink
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group