[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 205
  • Last Modified:

string

write functions to (a) left justify , (b)right justify ,(c) center justify agiven string. Test the fuctions with 5 strings
0
samuelccs
Asked:
samuelccs
1 Solution
 
scrapdogCommented:
Post the code you have so far.
0
 
jhurstCommented:
when I saw the previous question from you I thought that it may just be a coincidence that something I had set in class turned up.  Now that I see all the assignments here I am much more suspicious.
0
 
rsongylCommented:
Easily done

Tip: See the size of your string and then do calculation when a string is entered.

For right justification ... you just use the puts() command
For Left, use strlen() function to count your input string. Use the array size minus the strlen(input_string). Get the result and start from that index.
For centre, use the % the input string by 2. Then take the remainder minus from %2 of index. Start from the
index[(%2index-remainder)].
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now