Help with strlen
May 20, 2013 at 4:51pm UTC
So I created a box of asterisk so that I can output my data into so it'll look something like this
************
* *
* *
* *
* *
* *
************
But when I output datas into it, it becomes distorted.
************
* Hello *
* World! *
* It's *
* Me! *
* *
************
I know what I'm suppose to do, but I just don't know how to implement it. I'm suppose to use the strlen to get the length of the string and then subtract that string from the spaces in between the box.
1 2 3
//printf("%c %s %c",'*',var1,'*');
int format1 = 12 - strlen(var1);
printf("%c %s&format1c" ,'*' ,var1,'*' );
But it won't read format1. So my question is how can I implement this so that all the asterisks on the right will automatically format to fit the box?
May 20, 2013 at 4:59pm UTC
Last edited on May 20, 2013 at 5:00pm UTC
May 20, 2013 at 6:02pm UTC
Thank you for sending me the link. It did solve my problem.
Topic archived. No new replies allowed.