Forum Topic: C++: Main

(11,179 views • 122 replies)

This topic is 5 pages long. [ 1 | 2 | 3 | 4 | 5 ]

<< < > >>
None

AtomicPotato

Reply To Post Reply & Quote

Posted at: 4/16/06 12:51 PM

AtomicPotato LIGHT LEVEL 11

Sign-Up: 06/28/04

Posts: 474

This took me nearly forever to write, but I did it.

A tutorial about Pointers!

It's going to be confusing to some people, but I tried my best at giving examples.

This sentence is funnier than Disaster Movie.
=====
A Youtube Poop :: DotA [Potato Mix] - LISTEN!!

BBS Signature

None

shazwoogle

Reply To Post Reply & Quote

Posted at: 4/28/06 11:46 PM

shazwoogle NEUTRAL LEVEL 10

Sign-Up: 09/27/04

Posts: 2,661

page 3 and now windows API that makes a sad shazwoogle


None

neowolf22964

Reply To Post Reply & Quote

Posted at: 5/11/06 01:14 PM

neowolf22964 EVIL LEVEL 08

Sign-Up: 05/01/04

Posts: 190

Sorry, this is just a post to get this topic up in the forums =P

Woot C++ main!


None

FlashStation

Reply To Post Reply & Quote

Posted at: 5/14/06 07:21 AM

FlashStation EVIL LEVEL 07

Sign-Up: 02/26/05

Posts: 246

It seems to me that only a handful of users on NG only code with C++, come on guys, there has to be more.


None

FlashStation

Reply To Post Reply & Quote

Posted at: 5/14/06 07:53 AM

FlashStation EVIL LEVEL 07

Sign-Up: 02/26/05

Posts: 246

I AM ELITE

Tell me what you thinkC++ : Constants


None

dELtaluca

Reply To Post Reply & Quote

Posted at: 5/18/06 12:30 PM

dELtaluca LIGHT LEVEL 20

Sign-Up: 04/16/04

Posts: 5,117

I was going to do something like this when C++ main first started, but couldnt be arsed when i got half way through and computer restarted :P but ive done it now

C/C++ Linked List (theory)

http://newgrounds.co../topic.php?id=488121

i say theory, because it explains everything behind linked lists and doubly linked lists, and the sample i give, only deals with adding and removing items from start and end of linked list

with an extra example at end for random access in a singly linked list

My social worker says im special!

BBS Signature

None

CaptinChu

Reply To Post Reply & Quote

Posted at: 5/21/06 04:29 PM

CaptinChu DARK LEVEL 15

Sign-Up: 09/11/05

Posts: 3,207

Captin chu's guide to basic C++! (Part I)

All programming problems can be solved with Arrays!

BBS Signature

None

Naois

Reply To Post Reply & Quote

Posted at: 5/22/06 08:35 PM

Naois LIGHT LEVEL 20

Sign-Up: 10/31/05

Posts: 551

I'd like to request a tutorial on Functions from one of the C++ masters here.


None

CaptinChu

Reply To Post Reply & Quote

Posted at: 5/22/06 09:17 PM

CaptinChu DARK LEVEL 15

Sign-Up: 09/11/05

Posts: 3,207

At 5/22/06 08:35 PM, Naois wrote: I'd like to request a tutorial on Functions from one of the C++ masters here.

C++: Basic Functions

Made upon your request.

All programming problems can be solved with Arrays!

BBS Signature

None

Naois

Reply To Post Reply & Quote

Posted at: 5/25/06 04:48 PM

Naois LIGHT LEVEL 20

Sign-Up: 10/31/05

Posts: 551

At 5/22/06 09:17 PM, CaptinChu wrote: C++: Basic Functions
Made upon your request.

Thanks!


None

Jcrypt

Reply To Post Reply & Quote

Posted at: 5/25/06 09:02 PM

Jcrypt EVIL LEVEL 11

Sign-Up: 08/23/05

Posts: 926

What shoudl I write my next tutorial on?? Iv'e been wanting to write one for some time just don't know what


None

sheffgb

Reply To Post Reply & Quote

Posted at: 5/26/06 12:51 PM

sheffgb FAB LEVEL 09

Sign-Up: 06/14/05

Posts: 2,500

can i request a tutorial on classes/member functions?

i have never really used a class.

thanks!


None

Jcrypt

Reply To Post Reply & Quote

Posted at: 5/26/06 01:57 PM

Jcrypt EVIL LEVEL 11

Sign-Up: 08/23/05

Posts: 926

At 5/26/06 12:51 PM, sheffgb wrote: can i request a tutorial on classes/member functions?

i have never really used a class.

thanks!

Yes, I got dibs on this one fellas :D i'll start it later today or early tomorrow morning!


None

Naois

Reply To Post Reply & Quote

Posted at: 6/17/06 05:10 PM

Naois LIGHT LEVEL 20

Sign-Up: 10/31/05

Posts: 551

At 5/26/06 01:57 PM, Jcrypt wrote:
At 5/26/06 12:51 PM, sheffgb wrote: can i request a tutorial on classes/member functions?
Yes, I got dibs on this one fellas :D i'll start it later today or early tomorrow morning!

So... Are you going to actually do it? It's been almost a month...


None

iv00w

Reply To Post Reply & Quote

Posted at: 6/18/06 12:14 PM

iv00w EVIL LEVEL 08

Sign-Up: 04/24/05

Posts: 375

omg i keep getting this problem, with every program:

when i insert for example this code:

#include <iostream>

int main()
{
std::cout << "Hello World!";
char response;
std::cin >>response;
return 0;
}

and then hit compile and run, the program wont run, and i get an error telling me that some file is not found.
Please help me, i get this with every program!


Happy

Jcrypt

Reply To Post Reply & Quote

Posted at: 6/18/06 04:47 PM

Jcrypt EVIL LEVEL 11

Sign-Up: 08/23/05

Posts: 926

It sounds to me your header file 'iostream' is what it's saying is not found... if this is the case re-install your compiler seeing as the paths were messed up.


None

CaptinChu

Reply To Post Reply & Quote

Posted at: 7/11/06 12:16 PM

CaptinChu DARK LEVEL 15

Sign-Up: 09/11/05

Posts: 3,207

At 6/18/06 12:14 PM, iv00w wrote: omg i keep getting this problem, with every program:

when i insert for example this code:

#include <iostream>

int main()
{
std::cout << "Hello World!";
char response;
std::cin >>response;
return 0;
}

and then hit compile and run, the program wont run, and i get an error telling me that some file is not found.
Please help me, i get this with every program!

I'm sorry for the late response, but I see the problem. Are you used to typing in php code? If so, that might explain why the error existed.

You see, C++ is not a dynamic language. You must put ALL of your declared variables at the top of int main()

I hope that helps. If it doesn't, oh well...

BTW, I made a big, awesome tutorial on Structures and Classes. It doesn't quite go in-depth with classes yet, but I'm going to probably add that later in the topic.

All programming problems can be solved with Arrays!

BBS Signature

None

Trapped-Light

Reply To Post Reply & Quote

Posted at: 8/1/06 09:58 PM

Trapped-Light LIGHT LEVEL 04

Sign-Up: 05/31/06

Posts: 462

At 6/18/06 12:14 PM, iv00w wrote: and then hit compile and run, the program wont run, and i get an error telling me that some file is not found.
Please help me, i get this with every program!

I tried it and it worked fine.

have I just bumped a really old thread? oh well

None

0x41

Reply To Post Reply & Quote

Posted at: 8/1/06 11:34 PM

0x41 EVIL LEVEL 10

Sign-Up: 12/30/04

Posts: 551

At 7/11/06 12:16 PM, CaptinChu wrote: You see, C++ is not a dynamic language. You must put ALL of your declared variables at the top of int main()

You're thinking of C. C++ allows for variable initialization any where.

#include <iostream>
using namespace std;

int function(int);

int main()
{
int a = 5;
cout<<a<<endl;
int b = 6;
cout<<b<<endl;
int c = 7;
c = function(c);
cout<<c;
return 0;
}

int function(int c)
{
return c+5;
}


None

thingie-348

Reply To Post Reply & Quote

Posted at: 8/12/06 03:00 PM

thingie-348 EVIL LEVEL 07

Sign-Up: 11/27/05

Posts: 1,170


None

CaptinChu

Reply To Post Reply & Quote

Posted at: 8/13/06 09:25 AM

CaptinChu DARK LEVEL 15

Sign-Up: 09/11/05

Posts: 3,207

Captin Chu's Guide to basic C++ (part two)

I really hope the guides that I've been making were helpful.

All programming problems can be solved with Arrays!

BBS Signature

None

thecoshman

Reply To Post Reply & Quote

Posted at: 8/13/06 10:45 AM

thecoshman DARK LEVEL 11

Sign-Up: 06/11/06

Posts: 812

I am requesting a nice guide on how to use the swith function in c++, i think it is called a swicth. the command that lets you go,

if a =

1 > do this
2> do this

etc.

as you can, i have no idea how it works for c++


None

0x41

Reply To Post Reply & Quote

Posted at: 8/13/06 12:44 PM

0x41 EVIL LEVEL 10

Sign-Up: 12/30/04

Posts: 551

At 8/13/06 10:45 AM, thecoshman wrote: I am requesting a nice guide on how to use the swith function in c++, i think it is called a swicth. the command that lets you go,
if a =
1 > do this
2> do this
etc.
as you can, i have no idea how it works for c++

It's basically a cleaner way to write comparison statements. Don't know if it warrants it's own tutorial though.
---------------
int iValue = 0;
cin>>iValue;
switch(iValue){
case 1: cout<<"You entered 1\n";
break;
case 5: cout<<"You entered 5\n";
break;
default: cout<<"You entered something besides 1 or 5\n";
}
--------------- is equivalent to
int iValue = 0;
cin>>iValue;
if(iValue == 1) cout<<"You entered 1\n";
else if(iValue == 5) cout<<"You entered 5\n";
else cout<<"You entered something besides 1 or 5\n";
--------------is equivalent to
int iValue = 0;
cin>>iValue;
iValue == 1 ? cout<<"You entered 1\n" : iValue == 5 ? cout<<"You entered 5\n" : cout<<"You entered something besides 1 or 5\n";


None

phyconinja

Reply To Post Reply & Quote

Posted at: 8/18/06 09:28 PM

phyconinja EVIL LEVEL 25

Sign-Up: 09/18/04

Posts: 2,838

At 8/13/06 12:44 PM, 0x41 wrote: stuff

can some one like make a tut.. and explaining this?
Im lost at the biggining..


None

CaptinChu

Reply To Post Reply & Quote

Posted at: 8/18/06 09:34 PM

CaptinChu DARK LEVEL 15

Sign-Up: 09/11/05

Posts: 3,207

At 8/18/06 09:28 PM, phyconinja wrote:
At 8/13/06 12:44 PM, 0x41 wrote: stuff
can some one like make a tut.. and explaining this?
Im lost at the biggining..

Some day, I'll make my third part to my guide of basic C++. In that, I'll explain if, else, switch, more on functions, and basic structures and classes.

For those few who were wondering, I will stop at the fourth and final part of basic C++, "The last of what I know." It will be on extended classes and everything I know about ios. If you could get through all four parts of my guides... yea, you'd pretty much know everything I do about C++. Pretty pathetic, really. : /

All programming problems can be solved with Arrays!

BBS Signature

None

thoughtpolice

Reply To Post Reply & Quote

Posted at: 8/18/06 10:19 PM

thoughtpolice DARK LEVEL 10

Sign-Up: 03/24/03

Posts: 3,070

At 8/1/06 11:34 PM, 0x41 wrote: You're thinking of C. C++ allows for variable initialization any where.

[austin@continuum ~]$ cat c99.c
#include <stdio.h>

int whoom() {
return 5;
}

int main() {
int asdf = 5;
printf("%d\n",asdf);
char whoa[] = "datum";
printf("%s\n",whoa);
asdf = whoom();
printf("%d\n",asdf);
return 0;
}
[austin@continuum ~]$ gcc -std=c99 -Wall c99.c
[austin@continuum ~]$ ./a.out
5
datum
5
[austin@continuum ~]$

thanks 'bekko.
Xbox Live gamertag: muffin noodle
the empty set


None

0x41

Reply To Post Reply & Quote

Posted at: 8/18/06 11:42 PM

0x41 EVIL LEVEL 10

Sign-Up: 12/30/04

Posts: 551

At 8/18/06 10:19 PM, KurtGodel wrote:

:code

hmmm, getting some conflicting information here :-O.

http://en.wikibooks...rogramming/Variables

"In C, all variable declarations (except for globals) must be done at the beginning of a block. You cannot declare your variables, insert some other statements, and then declare more variables. Variable declarations (if there are any) are always the first part of any block."
Are you compiling the C program with a C++ compiler? Maybe I'm (and the wiki editors) are getting C rules and C conventions confused with each other.


None

thoughtpolice

Reply To Post Reply & Quote

Posted at: 8/20/06 03:23 PM

thoughtpolice DARK LEVEL 10

Sign-Up: 03/24/03

Posts: 3,070

At 8/18/06 11:42 PM, 0x41 wrote: Are you compiling the C program with a C++ compiler? Maybe I'm (and the wiki editors) are getting C rules and C conventions confused with each other.

Well, IIRC the C99 standards say it is so (I'll take a look and get back to you later.) It is highly dependent on the compiler too, many compilers don't abide by the most recent standards. GCC does and there are some others, but don't expect the code I posted to compile on, say, Open Watcom.

thanks 'bekko.
Xbox Live gamertag: muffin noodle
the empty set


None

TenLetters

Reply To Post Reply & Quote

Posted at: 8/21/06 11:50 PM

TenLetters LIGHT LEVEL 04

Sign-Up: 09/15/05

Posts: 164

Oh Noes i missed this page. >:(


All times are Eastern Standard Time (GMT -5) | Current Time: 12:52 PM

<< Back

This topic is 5 pages long. [ 1 | 2 | 3 | 4 | 5 ]

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!