我想将代码放在此程序的输出屏幕中心。我不知道如何和我试图在printf
之前放置间距命令但是不起作用。
#include <stdio.h>
#include <string.h>
char people [] = "HELLO"; // [] lets computer to determine
// the size of array for you!
// function spacing
void spacing(int numOfLines, int numOfSpaces)
{
for (int x=0; x<numOfLines; x++)
printf("\n");
for (int x=0; x<numOfSpaces; x++)
printf(" ");
}
// Using For Loops and Strings
void display()
{
int i;
for(i=0; i < strlen (people); i++)
spacing(2, 10);
printf("%c\n", people[i]);
}
// Main program
int main()
{
display();
getchar();
}