0

I NEED FAST HELP

I WANT TO PRINTF TEXT OF FIRST 8 CHARACTERS PRECEDED BY FIVE BLANKS

21st Apr 2021, 9:57 PM
othneillo
othneillo - avatar
11 Answers
+ 1
And what is the problem?
21st Apr 2021, 10:19 PM
Solo
Solo - avatar
+ 1
if you really want, then do not restrain yourself, take and print 😃
21st Apr 2021, 10:29 PM
Solo
Solo - avatar
0
Hi Please i made some correction to my question
21st Apr 2021, 10:24 PM
othneillo
othneillo - avatar
0
If someone inputs a string of lets say, 10 charaters, id like the compiler to pick the first 8 characters followed 5 blanks
21st Apr 2021, 10:26 PM
othneillo
othneillo - avatar
0
Is there a printf format for that? Ive seen printf commands like printf(‘%5s’, ‘helloworld’)
21st Apr 2021, 10:28 PM
othneillo
othneillo - avatar
0
Actually i need this info for an upcoming exam
21st Apr 2021, 10:30 PM
othneillo
othneillo - avatar
0
set the array length to 8, itll only take that much
21st Apr 2021, 10:45 PM
Slick
Slick - avatar
0
Ive gotten the answer guys printf("%5.8s\n", "Hello World\n"); /* Right-justify string with space for 15 chars, print only first 10 letters */ Thank you so much
21st Apr 2021, 10:52 PM
othneillo
othneillo - avatar
0
othneillo, did you really want this result?đŸ€”đŸ˜łâ˜ș
21st Apr 2021, 11:25 PM
Solo
Solo - avatar
0
Not exactly but something similar. I guess my question wasnt clear enough. Sorry
21st Apr 2021, 11:30 PM
othneillo
othneillo - avatar
0
if you want to print "Hello" with a indent of 8 characters: printf("%13.5s", "Hello World\n"); Output: Hello ................. Here's how it works: 13 is the length of the line, 5 is the number of characters in "Hello", 13-5 = 8 is the number of characters indent.
22nd Apr 2021, 12:01 AM
Solo
Solo - avatar