csindorf
asked on
right filling string till length = 5
Here is my code for starters:
if(strlen(wc)==0)
{
/*5 spaces */
strcpy(wc," ");
strcat(com_buffer, wc);
}
else
{
if(strlen(wc) != 5);
{
/* fill to the right with spaces till length = 5 */
strcat(com_buffer, wc);
}
else strcat(com_buffer, wc);
}
Where the comment is to fill to the right is where I need to insert the code that will take the length of wc if less than 5 anf fill it to the right with spaces. So if user inputs "a" wc becomes "a " and so on.
TIA
Craig
if(strlen(wc)==0)
{
/*5 spaces */
strcpy(wc," ");
strcat(com_buffer, wc);
}
else
{
if(strlen(wc) != 5);
{
/* fill to the right with spaces till length = 5 */
strcat(com_buffer, wc);
}
else strcat(com_buffer, wc);
}
Where the comment is to fill to the right is where I need to insert the code that will take the length of wc if less than 5 anf fill it to the right with spaces. So if user inputs "a" wc becomes "a " and so on.
TIA
Craig
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
BINGO
Given that you can skip the first case since you can append stuff to null strings with strcat.