I have written a program in Bloodshed using the C language for homework, but after clicking compile and run, I get an error message saying: Source file not compiled. I have ran compile only with it telling me that it's done, but when I compile and run afterwards, I get the same previous error message. How do I fix this? I am using windows 10 and here is the program:
/*TECH 1211 Computer Programming */
/*Mark Bowman */
/*Program Name "Formatted Output of Table" */
/*Spring 2019 */
#include<stdio.h>
#include<stdlib.h>
int main (void) {
printf("Mark Bowman\n\n");
char airline;
printf("Enter the first letter of the airline:");
scanf("%c",&airline);
int airline_number;
printf("Enter the flight number:");
scanf("%d",&airline_number);
int hour,minute;
char time_of_day;
printf("Enter the departure time as (hh:mm)");
scanf("%d:%d %c",&hour,&minute,&time_of_day);
float ticket_price;
printf("Enter the ticket price:");
scanf("%f",&ticket_price);
printf("\n\n\nAirline Flight\tDeparture\tTicket\n\t\tNumber\tTime\tPrice\n\t %c %d\t%d:%d %cm\t$%.2f\n\n\n--------------------------",airline,airline_number,hour,minute,time_of_day,ticket_price);
return(0);
}
I just came across this issue and it turns out Bloodshed Dev C++ is not compatible with Windows 10. It didn't even detect any errors during compilation if I intentionally added them.
Fortunatelly, there's this open source project called Embarcadero Dev-Cpp which is a port to Windows 10, they even have a portable version that works very well.
Related
So basically, I have this simple Hello World program and when executed, it outputs correctly.
#include <stdio.h>
int main(){
printf("Hello");
}
Output: Hello
But for some reason adding a scanf command will cause the program to not output anything. It will display that it's running but it won't display anything.
#include <stdio.h>
int num1;
int main(){
printf("Enter number: \n");
scanf("%d", &num1);
printf("%d", num1);
}
Output:
[Running] cd "d:\programming\" && gcc main.c -o main && "d:\programming\"main
I know my code is okay since I tried it on other IDEs and it worked correctly. I even copied code from the internet and tried to run in VSCode but it still didn't work. It still works perfectly fine yesterday but this problem just pops in nowhere.
I use Visual Studio Code 1.62.3 with C/C++, C/C++ Compile Run, and Code Runner extensions.
It's a buffering problem. When standard output (stdout, where printf writes) is connected to an actual terminal then it's line-buffered, which means output is actually written to the terminal when there's a newline.
However, VSCode probably uses its own terminal emulation and uses pipes to connect stdout to that terminal. That means the output will be fully buffered, and you need to explicitly flush it.
So modify the code as such:
printf("Enter number: \n");
fflush(stdout); // Actually write the output to standard output
scanf("%d", &num1);
printf("%d", num1);
That it works for the first example is because then the process terminates, and all output is flushed automatically.
i'm trying to use visual studio code to run various c programs but the code never outputs as it stays in a perpetual state of running.
Here's an example of the code i'm trying to run
#include <stdio.h>
typedef struct comp
{
float real;
float imag;
} complex;
complex mult(complex a,complex b)
{
complex c;
c.real=a.real*b.real - a.imag*b.imag;
c.imag=a.real*b.imag + a.imag*b.real;
return c;
}
int main()
{
float re,im;
complex a,b;
printf("Please enter the first complex number (re, im): ");
scanf("%f%f", &re, &im);
a.real = re; a.imag = im;
printf("Please enter the second complex number (re, im): ");
scanf("%f%f", &re, &im);
b.real = re; b.imag = im;
a = mult(a,b);
printf("Their product is %f + %fi \n", a.real, a.imag);
return 0;
}
And here is a screenshot of the application
As I said when I run the code it just get's stuck "running".
I've downloaded the necessary extensions for visual studio code that let you run C/C++.
Anyone encountered this problem before?
Thanks
You need to correctly configure your Code Runner extension from the generated JSON config under .vscode folder in your workspace. Also, you might haven't focused you've opened GitHub Authentication output log, not the code runner's if it actually ran successfully, which doesn't seem:
If you find it hard to configure, then switch to the Terminal section and type the following command to compile and execute it manually:
gcc -Wall -o main main.c; ./main # for PowerShell
gcc -Wall -o main main.c && main # for Command Prompt
I was facing the same problem. Follow the below steps and I hope it will work for you too.
CTRL+SHIFT+X
Type in search box Code Runner
Install the extension
Then click on File - Preferences - Settings
Type code run in the search box.
Scroll down until you find Code-runner: Run In Terminal. Check the box Whether to
run code in Integrated Terminal.
Restart VS Code
I have readed a lot of people with the same problem but the most of them are Windows Defender, in my case it only happens with avast(free version) and it detects this simple hello program compiled version:
#include <stdio.h>
int main()
{
printf("Name: ");
char name[20];
scanf("%s", name);
printf("Hello, %s\n", name);
return 0;
}
as "Win32:TrojanX-gen[Trj]" but some days ago i made another program and ran it into notepad++ console using cmd and nothing happened, is it a problem with avast or is it my pc?
Thank you.
First of all, I'm a begginer in C programming. I have been looking for a solution for a long time but I don't know what's going on with mi code or with Eclipse configuration. Basically, the problem occurs when I insert in the code a function from a external library. For some reason, eclipse is not able to debugg the code.
Let me explain that with a simple example:
Works incorrectly:
int main(void) {
char version[32];
puts("!!!Hello World!!!"); /* prints !!!Hello World!!! */
En2version(version);
printf("Version %s \n", version);
return 0;
}
Works correctly:
int main(void) {
char version[32];
puts("!!!Hello World!!!"); /* prints !!!Hello World!!! */
printf("Version %s \n", version);
return 0;
}
En2version() is the function took from the external library, and just eliminating it from the code it makes it work correctly.
I think the library is correctly linked to the project (there is no error when .lib is linked). Could you help me with some insight about what is happening?
Thank you all.
I don't see your #include
Whatever your are using, you need debugging symbols
either using the Program Database way if you have a .pdb
either using the Embedded Symbols way if you have a no .pdb
I have installed MinGW on netbeans for C and C++ programming.
Here is a simple code that I am trying to run on netbeans :
#include <stdio.h>
int main(int argc, char** argv) {
printf("Inside Main...\n");
int n;
printf("Enter : ");
scanf("%d", &n); // When I remove this line, it is working.
printf("You have entered %d.", n);
return (1);
}
Whenever I try to access any value from netbeans console, I don't see anything.
Output with scanf(...)
Output without scanf(...)
And if I try to run these code from cmd, all are working
for scanf() you must use Netbeans External Terminal !
Normal Run
You can also use Netbeans Standard Output !
But this is more misleading.
While you see an empty Terminal do input 123
after hit enter , you get the output all at once .
I had the same issue while running a CPP program.External output didn't helped me. I set the console type to Standard output and it solved the issue.
Right Click cpp Application-->properties-->run--->Consoletype to standard output