Question about C
Moderator: Moderators
Question about C
#include <stdio.h>
int main()
{
printf("This is output from my first program!\n");
return 0;
}
###
Then I run the sample program above it opens only for a eye blink and then quits. Does that happens because its not programed to wait or it should wait and so the problem is with my compiler?
int main()
{
printf("This is output from my first program!\n");
return 0;
}
###
Then I run the sample program above it opens only for a eye blink and then quits. Does that happens because its not programed to wait or it should wait and so the problem is with my compiler?
run this
what your program sais is
ok
get some headers
start the main bit
print something
return a good old exit code to windows
windows gets this, knows the application has finished, closes it
so no, nothing is wrong with your program... in a way
Code: Select all
#include <stdio.h>
int main()
{
printf("This is output from my first program!\n");
system("pause");
return 0;
}
what your program sais is
ok
get some headers
start the main bit
print something
return a good old exit code to windows
windows gets this, knows the application has finished, closes it

so no, nothing is wrong with your program... in a way

- BlackLiger
- Posts: 1371
- Joined: 05 Oct 2004, 21:58
Re: Question about C
Yes... Try using sleep or something similar (even a getc or scanf).manored wrote:Does that happens because its not programed to wait
lol
Quite frankly start with C++ instead of C and read up on OOP, that's the way to go. Knowing C doesn't really help with C++ a lot. Also if you are interested in AI coding, most of the AIs are in C++.
Your typical hello world
The same with very basic OOP
Haven't checked wether it runs or not nor if the syntax is correct though.
Quite frankly start with C++ instead of C and read up on OOP, that's the way to go. Knowing C doesn't really help with C++ a lot. Also if you are interested in AI coding, most of the AIs are in C++.
Your typical hello world
Code: Select all
#inlcude <iostream.h>
void main(int argc, char* args[])
{
cout << "HOLLA WOLRD!" << endl;
cin.get();
}
Code: Select all
#inlcude <iostream.h>
class CHollaWorld {
CHollaWorld();
~CHollaWorld();
void Spam();
};
void CHollaWorld::Spam() {
cout << "HOLLA WOLRD!" << endl;
cin.get();
}
void main(int argc, char* args[])
{
CHollaWorld HelloWorld;
HelloWorld.Spam();
}
Haven't checked wether it runs or not nor if the syntax is correct though.
Most minor AIs with AI devs learnign to code in C based languages (SAI by spectre, TAI by me) usually do it very badly because they use C style arrays for everything, and have no thoughts about proper object orientated modularity with usage of containers and other STL niceties.
This usually means the AI has a short lifespajn as it isnt flexible enough to expand and become more advanced and mature. AI needs modularity in the extremes. They need to be highly extendable in their design.
This usually means the AI has a short lifespajn as it isnt flexible enough to expand and become more advanced and mature. AI needs modularity in the extremes. They need to be highly extendable in their design.
- PauloMorfeo
- Posts: 2004
- Joined: 15 Dec 2004, 20:53
- PauloMorfeo
- Posts: 2004
- Joined: 15 Dec 2004, 20:53
I can't believe its not obvious that <my language(s) of choice> are clearly superior! For example, <my language(s) of choice> has the following:
1) Ease of use
2) <More stuff>
3) Plus, there's <some random number of applications> well-known applications coded in it!
<Conspicuous ignoring/shrugging off of bad points concerning language>
Clearly, it is superior!
1) Ease of use
2) <More stuff>
3) Plus, there's <some random number of applications> well-known applications coded in it!
<Conspicuous ignoring/shrugging off of bad points concerning language>
Clearly, it is superior!