r/C_Programming • • 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;
}
0 Upvotes

17 comments sorted by

11

u/dkopgerpgdolfg 1d ago

So, where are you stuck?

1

u/crisrb13yt 1d ago

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 1d ago

What compiler are you using?

1

u/crisrb13yt 1d ago

 MSYS2

1

u/__nohope 1d ago

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 1d ago

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().

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

u/Own_Unit_6170 1d ago

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

2

u/SmokeMuch7356 1d ago

What have you tried so far?

1

u/Legal-Demand-966 1d ago

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

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

u/Shattered-Spears 1d ago

Use "Code Blocks"

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 gcc

should 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.

  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