小编Ami*_*rti的帖子

错误:此处不允许函数定义。如何纠正这个问题?

这是代码:

#include<stdio.h>

int main(){

// prints I stars

void printIStars(int i) {

  // Count (call it j) from 1 to i (inclusive)

  for (int j = 1; j <= i; j++) {

    // Print a star

    printf("*");

  }

}


// prints a triangle of n stars

void printStarTriangle(int n) {

  // Count (call it i) from 1 to n (inclusive)

  for (int i = 1; i <= n; i++) {

    // Print I stars

    printIStars (i);

    // Print a newline …
Run Code Online (Sandbox Code Playgroud)

c nested function nested-function function-definition

1
推荐指数
1
解决办法
2187
查看次数