Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 创建函数脚本(空格前置、选定字符和打印时间)_C - Fatal编程技术网

C 创建函数脚本(空格前置、选定字符和打印时间)

C 创建函数脚本(空格前置、选定字符和打印时间),c,C,我有一个尝试,但这个网站不会让我缩进它正确,我不断得到错误 为一个名为script的函数编写原型,该函数有三个输入参数。 第一个参数是要在一个项目开始时显示的空间数 线路。第二个参数是要在空格后显示的字符,以及 第三个参数是显示第二个参数的次数 在同一条线上 script(); int main() { script(); return 0; } double script() { int spaces, tim

我有一个尝试,但这个网站不会让我缩进它正确,我不断得到错误 为一个名为script的函数编写原型,该函数有三个输入参数。 第一个参数是要在一个项目开始时显示的空间数 线路。第二个参数是要在空格后显示的字符,以及 第三个参数是显示第二个参数的次数 在同一条线上

    script();

    int main() {

        script();

        return 0;

    }

    double script() {

    int spaces, timesCharacter;
    char character;

    printf("Please enter in order the number of spaces preceeding a character\n");
    printf("the specific character to input and \n");
    printf("the number of times your want the character to display\n");
    printf("in order with a space in between each one: \n");

    scanf("%d %c %d", &spaces, &character, &timesCharacter);

    printf("%d %c %d", spaces, character, timesCharacter);

   }
上面这一行是问题行,我不知道如何打印空格

为一个名为script的函数编写原型,该函数有三个输入 参数

如何打印空格

带有参数和原型的函数,请查看以下代码:

#include <stdio.h>

double script(int spaces,char character, int timesCharacter );   //Function Prototype

int main() {

        int spaces, timesCharacter;
        char character;

        script(spaces, character,timesCharacter);  //Function Call 

        return 0;

}

double script(int spaces,char character, int timesCharacter) {  //Function Defination



        printf("Please enter in order the number of spaces preceeding a character\n");
        printf("the specific character to input and \n");
        printf("the number of times your want the character to display\n");
        printf("in order with a space in between each one: \n");

        scanf("%d %c %d", &spaces, &character, &timesCharacter);

        //printf("%d %c %d", spaces, character, timesCharacter);

        /*How to add spaces preceding*/
         printf("%*c", spaces, character);
        //To print the number of times
        int i=0;
        for(i = 1;i < timesCharacter; i++ ){
             printf("%c",character);
        }

}
#包括
双脚本(int空格、字符、int时间字符)//功能原型
int main(){
整数空格,时间字符;
字符;
脚本(空格、字符、时间字符);//函数调用
返回0;
}
双脚本(整数空格、字符、整数时间字符){//函数定义
printf(“请按顺序输入字符前面的空格数\n”);
printf(“要输入的特定字符,\n”);
printf(“您希望字符显示的次数\n”);
printf(“按顺序排列,每一个之间有一个空格:\n”);
scanf(“%d%c%d”、&空格、&字符、&时间字符);
//printf(“%d%c%d”,空格、字符、时间字符);
/*如何在前面添加空格*/
printf(“%*c”,空格,字符);
//打印次数
int i=0;
对于(i=1;i
这不会有任何错误