Return a matrix of a function in C

Asked

Viewed 1,019 times

0

Hello, I am doing a program in C that requires to be modularized, that the user registers the desired courses, prints on the screen the courses,but I want to use the matrix of courses, in another function, how to return this matrix to another matrix in main?

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

void nomecursos(int qtd){
    char matrizcursos[qtd][100];
    int i,confirm;
    do {
    for(i=0;i<qtd; i++){
        printf("Digite o %d curso\n",i);
        fflush(stdin);
        gets(matrizcursos[i]);
    }
    for (i=0;i<qtd;i++){
        printf("Cursos Cadastrados; %s\n", matrizcursos[i]);
    }
    printf("Confirmar cursos cadastrados ? Digite 1 para comfirmar ou 0 para cadastrar novamente\n");
    scanf("%d", &confirm);
    }while(confirm == 0);
    return;
}
int main(){
    int cursos;

    printf("Digite a quantidade de cursos\n");
    scanf("%d", &cursos);
    nomecursos(cursos);
    printf("Digite o nome do curso que deseja cadastrar uma proposta\n");

}
  • Doesn’t seem modularized to me.

  • What was requested or my code ?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.