r/C_Programming • • Oct 14 '26

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;
}
0 Upvotes

20 comments sorted by

12

u/dkopgerpgdolfg Oct 14 '26

So, where are you stuck?

1

u/crisrb13yt Oct 14 '26

The code doesn't work; it starts in the system tray, but VS Code says the file wasn't found or displays a fatal error: stdio.h: No such file or directory.

2

u/__nohope Oct 14 '26

What compiler are you using?

1

u/crisrb13yt Oct 14 '26

 MSYS2

0

u/__nohope Oct 14 '26

That's not a compiler. You're probably using GCC if you're using MSYS2.

There is no good reason to use those tools in 2026.

Use MSVC or Clang on Windows

If you want a Linux environment on Windows use WSL with GCC or Clang.

1

u/mcsuper5 Oct 14 '26

It sounds like VS Code isn't configured to point to the compiler/headers/libraries, assuming a compiler is installed. I don't think VS Code installs a compiler. It should be easy enough to configure if you have gcc, clang or MS's C compiler installed.

It's worth noting that MS terminal apps don't reliably flush the output before requesting input by default. You may need to use flush() before scanf().

11

u/KeyAdhesiveness9481 Oct 14 '26

In general, "i tried X, I expected Y, i observed Z" is a good format for asking for help.

6

u/Own_Unit_6170 Oct 14 '26

Install the community version of Microsoft Visual Studio. It's free.

2

u/SmokeMuch7356 Oct 14 '26

What have you tried so far?

0

u/orbiteapot Oct 14 '26

Que compilador você tem? Eu recomendo o MinGW.

2

u/crisrb13yt Oct 14 '26

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/mcsuper5 Oct 14 '26

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 gcc

should be enough to get you started.

I don't know VS Code well enough for solid pointers there.

3

u/crisrb13yt Oct 14 '26

I did it, I followed that path.

  1. cd "C:\Users\Usuario\Desktop\Faculdade\Trabalhos\PIM IV-Trabalho de Analise de Dados"
  2. dir src.c
  3. gcc src.c -o sistema
  4. .\sistema.exe

The terminal was analyzing the wrong folder. Thanks for the help, guys

1

u/KeyAdhesiveness9481 Oct 14 '26

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/Legal-Demand-966 Oct 14 '26

Use vs code with c/c++ and runner extension

1

u/NYU_VM Oct 14 '26

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 Oct 14 '26

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:)

1

u/e-batters Oct 18 '26

Why, instead of Visual Studio Code, not opt for a real IDE? With Visual Studio Community, there is an edition of this IDE that is ‘free for students, open-source contributors, and individuals.’. If you want I can provide you with a pre-configured sample project that will directly allow you to compile your program.

-2

u/Shattered-Spears Oct 14 '26

Use "Code Blocks"