the build would never end - c

screenshot
I've just started learning C, so I've been practicing some basic codes.
I pressed F7 to initiate the build, but everything I get is the message like this-
build started...
===========Build: 0 succeeded, 0 failed, 1 up-to date, 0 skipped=========
I waited for over ten minutes and nothing would happen.
I made a new solution with the exact same code, but then it worked without problem.
what would be the problem...?

I wonder if you make any changes to your project Properties such as so that it cannot generate the executable program.
First, right-click on your C++ project Properties-->Configuration Properties-->General--> change Output Directories to $(SolutionDir)$(Configuration)\.
also change Intermediate Directories to $(Configuration)\.
change Target Name to $(ProjectName).
Besides, enter Linker-->General
change Output File to $(OutDir)$(TargetName)$(TargetExt)
After that, delete any Debug or Release,x64 folder under the solution folder and project folder.
Test it again.

Related

.exe files dissapear when they want in VS code

Things that i should note are that I am using the latest version of vs code to write in c, my compiler is mingw-w64. Whenever I run a simple code (Hello world for example) everything works then suddendly when I try to do something else a message appears saying (program name).exe was not found. This generally happens when I try to use commands from other libraries, i tries using conio.h textcolor() but it doesn't want to, but when i use getch() it works fine. Moreover the .exe file exists, then i add a single line of code and boom suddendly it doesn't exist. Can anyone explain to me what is going on??

Anyone know how to solve the error of "collect2.exe: error: ld returned 1 exit status" when a program in C is running?

First of all I'm at the first year of computer science so I'm a beginner in programming yet, then forgive me for my lack of knowledge. Well, my problem basically is an error that is shown in the screen everytime when I try to run(by the way I'm using Sublime Text) a program in C. In this case was a simple code:
#include <stdio.h>
int main() {
//print the heading of the game
printf("*****************************************\n");
printf("* Wellcome to the our guessing game *\n");
printf("*****************************************\n");
int secretnumber = 42;
int guess;
printf("What is your guess?");
scanf("%d", &guess);
printf("Your guess was %d \n", guess);
}
OUTPUT:
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot open output file Olamundo.exe: Permission denied
collect2.exe: error: ld returned 1 exit status
[Finished in 0.3s]
You know, i tried some solutions like move the folder where the executable lies and place it in the root(in my case Mateus(C:)), give all the permissions to the folder, turn off the antivirus(in my case i just using the Windows defender), finish the task using the the Task manager but nothing worked. Please, help me i really don't know what else i can do.
Overall, your problem is that you're trying to run a program that is interactive from within Sublime; it doesn't support that. Sublime captures output your program sends to stdout and stderr and displays it in the output panel, but it does't connect the panel to stdin.
So, the scenario you're encountering works like this:
You run your program, which is interactive (in your case it prompts for input via scanf(), and it launches and prompts you for input
You try to enter input, but nothing happens because stdin isn't connected.
You try to run your program again (or modify it and build it again thinking you might have an issue).
The version you previously tried to run is still running in the background waiting for input you can't provide, and windows locks executable files while the program is running. So, when the linker (collect2) tries to link the executable during the build, it can't because the file is locked, hence the permission error.
You can clear the error by killing the program running in the background, which you can do via the Tools > Cancel Build if you do it before this error occurs; if you've already seen the error this likely won't work because this only cancels the most recent build, which would be the one where the error occurred.
The other thing you can do is use something external to kill it; the task manager on windows, kill from a terminal on Linux/OSX, etc. You'll need to do it this way if you're already seeing the error.
Note however that this doesn't solve your underlying problem because you're still trying to run an interactive program. In order to do that from within Sublime you need to create a custom sublime-build that allows for this. Generally you'd either have it spawn an external terminal and run the program in there, or use a package like Terminus if you want to keep it internal.
In order to set this up, you need to be familiar with the sequence of commands that are needed to compile, link and run a program in one command, which you can get by checking what the build system you're currently using is (assuming you didn't create it yourself).
This video on buffering and interactive builds in Sublime (disclaimer, I'm the author) has information and examples of how Terminus can be used for something like this if you'd like more information.

adding multiple executables C-Lion

im pretty new in C-programming. I use CLion from JetBrains to program my stuff. I would like to know how to add multiple c files in the makelist.
i would like to just open a program and to execute it..if its possible
my ide works just for one file. so i always have to change the name of the c. file in the makelist
i have already tried a lot of combinations of the makelists file but nothing worked.
does somebody have an idea how to fix this problem?
I have edit two new pictures
In this example I have two c files which i would like to execute.
My goal is to add the whole c file tree on the left side to the CMakeList
Here are the pictures
!enter image description here
Here is the error log
enter image description here
Here is the solution. Thanks to your response someprogramerdude
I just added executables and i changed the project in the beginning. the reason why i use picture is that you can see the source files on the left side
enter image description here

I have a .c.save file. What is it? What does it do?

I am programming with C using Code::Blocks. My project is divided in 3, header, implementation and main.
Whenever I used a project, apart from the source files and the bin and obj folders I had a .depend and a .layout file. All good.
Now I created a new project, and just copied -> pasted everything new in source files. I did this twice.
For each case, I have a .c.save file, which has the same name of the implementation file (ie. the implementation file is called imp, then the file is called imp.c.save). I asked a friend of mine what it might be, and he said I need to beware as he had two random files created, which prevented him from building correctly (he got a stupid error). When the files were deleted everything went back to normal.
I did a short test of the program and I can find nothing different. I am hesitant to delete it since this cropped up twice in two cases, but I don't want to compromise my coding.
Tried to google and I didn't find much. Any help?
Well, it didn't cause any problems so I assuming it is an autosave file.

"Threat detected" from AVG when trying to run my C program

I've been working on a project I have to do for school,
They basically asked us to separate every question to a file of its own,
so what I was trying to do was comment the rest of the files or exclude them off the project, and when I try to 'Start without debugging', I end up getting this message. I did this before and everything was fine:
the weird part is that if i remove the solution and make a new one and only make one .c file it works...
I was also trying to remove the "Ex2" folder and made it again, it didn't help.
When I choose move to vault it doesn't find the file.
Edit: I've run a scan and it didn't find any infections on the computer and now that i'm trying to run the program i don't see the threat anymore, I only get this message:
Please, i would really appreciate some help (again... )
I it find very interesting that your build failed. As a result, it is HIGHLY likely that no output was built.Yet your virus scanner flags a compiled file.
If your code didn't compile, where did this executable come from?
Perhaps you do have a real virus?
It seems the last error, that is partially cut off, is "Link: Fatal Error LNK1104. Cannot Open File". That suggests that the file is locked, write-protected, or otherwise blocked.
Is anything else holding open your executable, which prevents recompilation?
I wouldn't blame your virus scanner from flagging an attempt to write to a running .exe as suspicious.

Resources