I wanted to write a simple hello world program in DOSBox, so I downloaded Bruce's C Compiler from here. And wrote this program:
#include <stdio.h>
int main() {
printf("Hello, World!\n");
}
I ran bcc like this: bcc -o hello hello.c, but I get this error every time:
C:\BCC\DEVEL\BCC\BIN\LD86.EXE: HELLO.C has bad magic number
I don't know why this is happening, if anyone can tell me please do.
Related
I wanted to extent my c knowledge to c++. Using Win10, I installed VSCode and mingw following the tutorials.
Next I created a Hello World test file.
It compiles properly without errors. However when I run it from a terminal window, I do not get any output.
I am sure its a stupid beginners mistake...
#include <iostream>
using namespace std;
int main(){
std::cout << "Hello Moon!";
std::cout.flush();
return 0;
}
compiling:
Kompilierung wird gestartet...
D:\msys64\mingw64\bin\g++.exe -fdiagnostics-color=always -g3 -Wall "D:\CPLUSPLUS\programs\hello world\hello world.cpp" -o "D:\CPLUSPLUS\programs\hello world\hello world.exe"
Die Kompilierung wurde erfolgreich abgeschlossen.
console:
PS D:\CPLUSPLUS\programs\hello world> "hello world.exe"
hello world.exe
PS D:\CPLUSPLUS\programs\hello world>
so obviously it runs the exe without complaint, however I do not see any output...
Any hints/ideas?
Thanks quimby! that did the job!
actually ist not my c++ vscode ignorance but the one of powershell (coming from cmd...)
so you are right: powershell did NOT run my program but rather just echo the quoted string.
so ones needs the & operator to do the job.
Problem solved
Thanks again.
i guess you need to remove the std:: prefix because you already imported the std
try this
#include <iostream>
using namespace std;
int main(){
cout << "Hello Moon!";
return 0;
}
I have made a simple Hello World program in C++.
But, for some reasons it is taking up almost 900kb.
I have no idea why it is so big. I am using -s, -Os and -Bdynamic I am using Code blocks.
I tried this: GCC C++ "Hello World" program -> .exe is 500kb big when compiled on Windows. How can I reduce its size?
My program:
#include <iostream>
int main()
{
std::cout << "Hello world" << std::endl;
return 0;
}
Yesterday i made a bigger program and it was only 21Kb.
Now every single of the executables are about 900Kb.
Info:
I tried to compile it myself using g++ Hello.cpp -Bdynamic -s -Os - Still the same size.
But when i compiled it using printf from <stdio.h> i got it to 21Kb.
I want to use <iostream>
(It is an updated version of my post)
Total novice C++ user going thru tutorials using Visual Studio Code on OSX. Barest bones Hello World program
#include <iostream>
int main()
{
std::cout << "Hello, World!";
return 0;
}
Then I run-compile in VSCodes terminal using
$ g++ Foo.cpp -o foo
My question is, shouldn't I be seeing the Hello, World! out put in the terminal? Or will this only be visible if I compile and run in Windows?
I do see an executable after compiling but nothing in the VS Terminal window.
You actually have to run the file. So, in this case, since you named your file "foo" with the -o command, you have to run ./foo from the terminal.
I’m trying to figure out how c bindings in crystal work. For starters I’m wondering how I would include a simple hello world c function into crystal. Always good to start with the basics right? Here’s the function I’d like to include:
#include <stdio.h>
void hello(const char * name){
printf("Hello %s!\n", name);
}
That took me a bit to figure out as well. First you'll have to compile your C file into an object. In gcc you would run gcc -c hello.c -o hello.o.
Then in the crystal file you'll need to link to the C object. Here's an example:
#hello.cr
#[Link(ldflags: "#{__DIR__}/hello.o")]
lib Say
fun hello(name : LibC::Char*) : Void
end
Say.hello("your name")
Now you simply have to compile your crystal app and it will work.
crystal build hello.cr
The last days I began learning C++. As with every language I began making a Hello World program. The code is:
#include <iostream>
using namespace std;
int main() {
cout << "I'm doomed in Windows :(" << endl;
}
I compiled it with g++ (from MinGW) like this:
g++ -c hello.cpp
g++ -o hello hello.o
The output is:
hello.exe
But when I open hello.exe it freezes / doesn't start. I tried both to open it via the command line as opening it with the GUI. It looks like this:
https://drive.google.com/file/d/0ByNRkSnhavxIaXh6a2JSaEpZV0k/view?usp=sharing
Does anybody know what's wrong? Thanks in advance!
PS: If you wonder why I didnt post the image inline, I can't. I need 10 reputation points for that ^^.
The problem is solved by deactivating Avast, thanks to Hans Passant. It is also possible to add the executable to the Avast exclusion list.