r/C_Programming • u/crisrb13yt • 1d ago
Question Beginner in C — need help compiling my program on Windows.
#include <stdio.h>
int main(void) {
int opcao;
do {
printf("\n=======================\n");
printf(" TECNFIX INFORMATICA\n");
printf("=======================\n");
printf(" 1 - Cadastrar Cliente\n");
printf(" 2 - Cadastrar equipamentos\n");
printf(" 3 - abrir Ordem de Serviço\n");
printf(" 4 - Consultar Ordem de Serviço\n");
printf(" 5 - Sair\n");
printf("===============================\n");
printf("Escolha uma opcao:");
scanf("%d", &opcao);
switch (opcao) {
case 1:
printf("Cadastro Clientes selecionados!\n");
break;
case 2:
printf("Cadastro de equipamentos selecionados!\n");
break;
case 3:
printf("abrir Ordem de Serviço!\n");
break;
case 4:
printf("Consultar Ordens de Serviço selecionado!\n");
break;
case 5:
printf("Encerrando o sistema TechFix...\n");
break;
default:
printf("Opcao invalida!. Tente novamente.\n");
}
} while (opcao != 5);
return 0;
}
8
u/KeyAdhesiveness9481 1d ago
In general, "i tried X, I expected Y, i observed Z" is a good format for asking for help.
6
2
1
1
u/NYU_VM 1d ago
No way to know what you have in terms of tools/compilers or what specifically you are trying to ask? You need compilers? Grab the gcc or clang toolchains provided by MSYS2. Or get an ide like Visual Studio. You want to use the command line? Use "gcc/clang filename.c". And for your code, improve it to follow a defensive style of coding, it's a bio hazard waiting to happen. Do not just look at the happy paths and just test by entering numbers 1 through 5. Input Anything else and it would be UB or some form of failure,..
3
u/mcsuper5 1d ago
He needs to walk before he runs. He's working on getting code to compile and run and we do ask for simplest programs that display the behavior when troubleshooting. Defensive coding can wait until next lesson:)
-2
0
u/orbiteapot 1d ago
Que compilador você tem? Eu recomendo o MinGW.
1
u/crisrb13yt 1d ago
eu tenho esse, mas quando eu tento iniciar o código ele diz que n achou o arquivo ou da fatal error ou fatal error: stdio.h: No such file or directory
1
u/KeyAdhesiveness9481 1d ago
This means that your system headers are missing or incorrectly configured. How exactly did you install your compiler? What command are you using to do the compilation, and where are you entering it?
I second the other comment telling you to install Visual Studio Community, and not use Visual Studio Code. Its a different program that will handle all the toolchain details for you.
1
u/mcsuper5 1d ago
While I use MinGW, I don't use it with VS Code. You can compile or run code under it if you install gcc which isn't a default package iirc. If you did install gcc with it, then from the MSYS shell try ```
assuming your file is mymenu.c and in current directory
gcc -o mymenu mymenu.c ./mymenu ```
If you want to use VS Code, I'd search "Installing gcc (or preferred C compiler) and VS Code on Windows 11". Some tutorials may even walk you through helloworld.c.
If you are content to use command line I'd go straight to WSL and install a development environment. Debian/Ubuntu:
sudo apt update sudo apt install build-essential gccshould be enough to get you started.
I don't know VS Code well enough for solid pointers there.
3
u/crisrb13yt 1d ago
I did it, I followed that path.
cd "C:\Users\Usuario\Desktop\Faculdade\Trabalhos\PIM IV-Trabalho de Analise de Dados"
dir src.c
gcc src.c -o sistema
.\sistema.exe
The terminal was analyzing the wrong folder. Thanks for the help, guys
11
u/dkopgerpgdolfg 1d ago
So, where are you stuck?