0
How can I make a blank space - example three spaces - before printing sth in C?
C language
6 Antworten
+ 4
I will post two programs, one handwritten(basic space program) and other as post(advance space program). So you can select your choice:-
This is a basic program to space:-
/* Function to n space.Create any number of space*/
void create_space(int n) {
int i=0;
for(i=1;i<=n;++i)
printf(" "); }
//driver program to function
main() {
create_space(3);
printf("There are 3 spaces before this\n\n");
create_space(5);
printf("There are 5 spaces before this\n\n"); }
Important Big Note:- Dont use '\n' New linefeed before the word or printf because it will skip the spaces and you won't get your desired output.Put it at the end of word/string or in the printf.
BELOW GIVEN IS AN ADVANCE PROGRAM:-
If you want advance program to spaces and formatting,then check this code out
https://code.sololearn.com/crtkXMM7zhqY/?ref=app
+ 3
Jist add spaces with the spacebar Retag Tarek
I have created an exaple code here:
https://code.sololearn.com/cYK6U1rY2J3S/?ref=app
+ 3
sorry i dont know any other way
+ 1
Agent Thank you
But I am making a for loop so this doesn't work for me it make space between the context itself so is there any other way?
And can I make the number of spaces varies every time the loop work?
+ 1
Agent never mind, Thank you 😄
0
for known number of spaces there's a trick:
printf("%3shello world\n","");