Problem with compilation in VS Code. IncludePath error - c

I have a big problem with compilation of my program in VS Code. I'm writing a simple program but when I try to compile it and run it shows 2 problems. (I'm trying to translate it as clear as I can).
There is a problem with element #include. Please upgrade element includePath.
Can't open source file "stdio.h"
I'm writing the program in C language. I have to say that I'm a fresh programmer so if you can help me, please write it as simple as it's possible.
I'm adding the program, but I think it's very simple and that's not the issue:
#include <stdio.h>
int main()
{
printf("costam\n");
return 0;
}

Related

C into shell code

I'm trying to get a shellcode using C. I cannot just take .obj file due to the large amount of nulls. I've also tried "Shellcode Compiler", but it hasn't helped me.
Are there any other projects which can help me, or any ways to create a useable shell code from C?
My simple C code:
#include <Windows.h>
int main()
{
WinExec("SomeFile", 0);
}
Seeing that c is a compiled language and not interpreted. I am sure you will get better results from converting the binary to shellcode.
Check out GitHub vulnwarex/bin2sc.

why does this error occur: 'conio.h' file not found

i'm new to C programing and i was testing some code when i compiled it this error came up:
fatal error: 'conio.h' file not found #include <conio.h>
this was on the top of the code i was testing:
#include <stdio.h>
#include <conio.h>
...
i searched about this error but i only found answers related to windows and ubuntu
i'm running mac os
conio.h is not a standard library header, and the functions it declares are not standard library functions - it's specific to an ancient implementation that isn't used much anymore. If the code you're trying to build uses conio routines like getch(), then it won't build on a Mac.
It depends of what compiler are you using.
Conio.h is mostly header for MS-DOS compiler, so it can be unavailable in some others packages.
If you tried to use getch() as tool to stop console from closing after execution, simply replace it with scanf():
int a;
scanf(%d,a);
Console will close after pressing Enter
See here Conio is dead already do not use my friend I have noticed many YouTubers in initial coding use getch() to make your code wait for you to press a key and when pressed it is done but now conio isn't even a part of c/c++ it works in MS-DOS based compiler and turbo-c++ but most of the turbo c++ code turns out erroneous as they use old c/++ syntax that is deprecated a long back in the history of development in c/c++.
#include <conio.h>
Suggestion : Remove These lines and voila it works
Happy Coding!
I encountered the same situation. My xcode suggested #include <curses.h> instead. I changed accordingly, now it builds.

Cannot compile C programs on CodeBlocks: Undefined reference to 'WinMain#16'

I'm new to C and I'm trying to compile a HelloWorld program. I'm using GNU GCC 4.9.2. I've looked online for many solutions but none of them worked: Every time I compile the program, it hits me with this error:
"Undefined reference to 'WinMain#16'"
Please bear in mind that I HAVE configured the project as a console project, not a windows project and that I have written the main function correctly.
Here's the code:
#include <stdio.h>
int main()
{
printf("Hello world!\n");
return 0;
}
Finally, note that I can successfully compile, build, and run C++ programs with code blocks. For some reason, I can't do the same for C. Additionally, I tried compiling the source file from the command line and the issue still persisted.
Compilation lines:
I solved the problem and I don't know how. I changed the C debugger from gcc to gnu, it gave me a different error. I then changed it back to gcc and it started working randomly. I've been trying to solve this problem for literally 6 hours. Then I try some random nonsense and guess what? it works.
I hate software development.
I love software development.

Keep getting indentifier undefined error in C using any ide

So this is my first post. I am preparing for some upcoming college courses on programming, one of them deals with C. I have been teaching myself for a little while and have never encountered this problem before, even though I have used the same code. I am having the issue on any ide that I use, which are MS Visual Studio 2019, and Codeblocks, both 16.01 and 17.12.
The problem is when I try to include an inline function, the compiler brings up an error: identifier "keep_window_open" is undefined, as well as the error: 'keep_window_open':identifier not found.
This never happened until I upgraded Codeblocks from 16.01 to 17.12, so that leads to believe something happened with the compiler or some settings that I don't know about, or how to change.
I have tried going back to Codeblocks 16.01, but still get the same error. All my previous programs, that use the exact same code still compile and run, so I am at a lost and completely frustrated. Enough so to think about changing my major, which I really do not want to do. I enjoy programming. But this problem is killing me.
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
inline void keep_window_open() { char ch; scanf("%s", ch); }
int main()
{
printf ("Lets see if this stupid thing works\n");
keep_Window_open();
return 0;
}
The problem is the line of code:
keep_Window_open();
If I comment it out, the program will compile and run, however I can't see it, because all it does is flash and then close the console window. And I need to use this code to see the output window. As I have said I have used this code in many other programs, most of which are much more complex than this, and they all still compile and run. It is only on new projects that I try to create.
I expect the window to stay open until the user presses and enters a key, like it always has before. I am stuck, and would appreciate some input on how to proceed, other than throw myself in front of a bus.
OK, so I was able to solve the issue in CodeBlocks, but not in Visual Studio. I changed the code to have the inline function below the main function, and now when compiled and run in CodeBlocks (17.12) it works exactly like it should, or how I thought it should.
However when I try the same solution in Visual Studio, after putting the inline function below the main function I now get a new error:
'keep_window_open' redefinition basic types
Since I usually use CodeBlocks for C, Visual Studio for C++ and intellij for java, I am not going to worry about this, as long as it works in CodeBlocks I should be OK. However I am curious as to why it work in one IDE and not the other?
I am new to this programming thing, and there is much to learn, and I know virtually nothing about compilers and linkers, as I am focusing on programming techniques and syntax in several different languages.

how to avoid writing main() too many times in C?

Let say I have 5 small piece of codes in C.
Every time I want to test each piece of code, I have to repeat this process:
#include <stdio.h>
int main()
{
// code piece go into here
return 0;
}
Is there way that I don't have to do this 5 times? I'm using Code::Blocks, that means I have to create 5 different projects, which I believe not necessary because each piece of code is small.
Is this really so hard? Every program you run needs a main function, and the text you've pasted there isn't very long. Also, people expect to see a main function in C/C++ programs. If you template this out somehow, you're just going to make your code confusing.
If the issue is that you have to make a project for every test you want to build, then I would guess you are not using your IDE correctly. Is there not a multi-target project type that lets you have multiple test programs without all the extra project files? If there is not, then perhaps you should be using a different IDE.
Use a good editor with code templates. Most feature-full editors (Emacs, vi, Scite, Textmate, or even MSVC if that's your cup of tea) have some support for them. This way, writing this boring template every time will take only a fraction of the second.
Would template files or copying and pasting be too difficult for some reason?

Resources