i'm learning.......C

Anything not relating to the X-Universe games (general tech talk, other games...) belongs here. Please read the rules before posting.

Moderator: Moderators for English X Forum

Post Reply
P88
Posts: 1456
Joined: Wed, 6. Nov 02, 20:31
x2

i'm learning.......C

Post by P88 » Wed, 29. Oct 03, 22:49

Code: Select all

#include <stdio.h>

int main()

{

int a;

printf("Enter a value above or below 50...\n\n");
scanf("%d", &a);

if (a > 50)
   printf("You entered a number over 50 :)\n\n");
   
   else if (a == 0)
             printf("You entered zer0 hehe.\n\n");
   
   else
         printf("You entered a numba below 50 =-]\n\n");
         
         printf("...........................................An 'effort' by Pointer88 :)");
              
              
      
      return 0;
      
      }
      
that is the source for my little program i made tonight.

aye i aint doing to bad i think, i've decided im going to try and learn C, i've remember all of the above without turning to my notes on what to write :wink: considering i didnt have a clue what any of that printf or scanf etc... meant yesterday, i do today :twisted:

click HERE to see my little effort in action :wink: dont worry i guarentee you its clean and nothing bad about it and only contains the above ^^^^ code.

reckon im going anywhere? note i made this after a few hours of reading/trying to understand what the basics are, and im willing to learn :!:

id be thankful if anyone could give me any pointers about learning C?

thanks :)

-TD-13-
Posts: 3172
Joined: Wed, 6. Nov 02, 20:31
x3

Post by -TD-13- » Wed, 29. Oct 03, 23:35

Why not C++ instead of C?

I'm not sure, but I think C++ is a more newer updated and easier version of C?

I know C++ by heart, and I've made everything from Pac-Man to my own creations, "Helldiver Battleship" and "InSaNiTy PoNg!!!" to name a few(good ones anyway...).

Your off to a good start, and the programs get much more fun as you advance along. :)


Not sure but when I get to this line

Code: Select all

scanf("%d", &a); 
it crashes out and scans my A: drive....

Think about C++ though. If you need anyhelp in any of it just ask, as I might be able to help.


Keep going! I found programming to be a blast.

P88
Posts: 1456
Joined: Wed, 6. Nov 02, 20:31
x2

Post by P88 » Wed, 29. Oct 03, 23:44

ahh ok then :) i've looked for "easy to understand" tutorials on C++ and could not find any :roll:

i need a tutorial that basically spells it out for me, this equals this, this means this, if you do this then this does this etc....so i can learn and get the hang of it :wink:

cheers :)

Deleted User

Post by Deleted User » Wed, 29. Oct 03, 23:44

C++, where do we start ? :)

-TD-13-
Posts: 3172
Joined: Wed, 6. Nov 02, 20:31
x3

Post by -TD-13- » Thu, 30. Oct 03, 00:06

I am a C++ tutorial.

Cool. Give me a few minutes and I will post a program that is the same exact thing as yours, only it will be in C++. I will also comment each line.

Its C++ time....

Code: Select all

#include<conio.h>
#include<iostream.h>

void main()
{
   int number;
   cout<<"Enter a number either lower or higher than 50 \n \n";
   cin>>number;
   
   if(number>50)
      cout<<"You entered a number higher than 50! \n \n";
   
   else if(number==0)
      cout<<"You entered zer0 hehe. \n \n";

   else
       cout<<"You entered a numba below 50 =-] \n \n";

   cout<<"An effort........................ by Pointer88 :) ";

 }
Ok heres the breakdown:

Code: Select all

cout<<
// this mean "Console Output" which is the equivelent of printf()

Code: Select all

cin>>   
//this means "Console Input " same as your scanf

//oh and the << >> arrows just point to where the info is going for instance:

Code: Select all

cin>>number;
// it literally reads: "Console Input is going into the varible 'number'"

Code: Select all

void main()
//every C++ program should have one, its like the main body of the program, where the computer starts. Because its a void, there is no need for "return 0;"

Code: Select all

#include<conio.h>
#include<iostream.h>
//These two just let you input output and such. You really don't need to know much more than that about 'em.


Hope this helps! :) Any other questions feel free to ask!
Last edited by -TD-13- on Thu, 30. Oct 03, 21:37, edited 1 time in total.

P88
Posts: 1456
Joined: Wed, 6. Nov 02, 20:31
x2

Post by P88 » Thu, 30. Oct 03, 00:13

either some of that code is wrong of my C compiler wont compile C++ :D

-TD-13-
Posts: 3172
Joined: Wed, 6. Nov 02, 20:31
x3

Post by -TD-13- » Thu, 30. Oct 03, 00:36

P0inter88 wrote:either some of that code is wrong of my C compiler wont compile C++ :D
Yes, you C compiler won't compile C++. You have to get another compiler for that. My favorite is Turbo C++.
Its easy, although old and not the most state of the art, its simple and gets the job done with minimal confusion. And it can make some pretty cool looking stuff.

Because of its "oldness" you can download it (legally!) for free here:

http://community.borland.com/article/0, ... 51,00.html

P88
Posts: 1456
Joined: Wed, 6. Nov 02, 20:31
x2

Post by P88 » Thu, 30. Oct 03, 00:56

when i try and install that compiler it says insert disk :?

...i aint got the one needed

Sir Crashalot
Posts: 3846
Joined: Wed, 6. Nov 02, 20:31
x4

Post by Sir Crashalot » Thu, 30. Oct 03, 01:04

When you start to install it, it asks for a source drive which is where you are installing from, it defaults to A: drive. Change it to the drive you have unpacked the file to.
If you can`t dazzle them with dynamics, then baffle them with bullsh*t :D

P88
Posts: 1456
Joined: Wed, 6. Nov 02, 20:31
x2

Post by P88 » Thu, 30. Oct 03, 01:11

yeah i did that, i put it to the C: drive but it still asks for disk

Sir Crashalot
Posts: 3846
Joined: Wed, 6. Nov 02, 20:31
x4

Post by Sir Crashalot » Thu, 30. Oct 03, 01:17

Strange..it worked fine for me.

I downloaded mine to E: drive
Unpacked it to E:\turboc

When I started installing, I set the source drive to E:
The next option was the path which pointed to the right place so no changes there.
Then I just installed it..

Did you try installing it by going to the directory and clicking the install icon? (I did it this way)

Or did you try to install it through DOS ?
If you can`t dazzle them with dynamics, then baffle them with bullsh*t :D

pjknibbs
Posts: 41359
Joined: Wed, 6. Nov 02, 20:31
x4

Post by pjknibbs » Thu, 30. Oct 03, 08:33

TD, you need to edit your code--in the actual code block you have cin>>a, not cin>>number! The code you posted there (a) won't compile because the variable "number" doesn't exist and (b) would give ambiguous results if it DID compile...

JadeNova
Posts: 1120
Joined: Wed, 6. Nov 02, 20:31
x3tc

Post by JadeNova » Thu, 30. Oct 03, 10:40

Where do you guys learn all this stuff, we never had these options when I was in College. :(

I just finished HTML and have begun PERL and it's driving me crazy. I already have a job so I'm doing it through evening classes.

I'm having to take additional classes just for the maths cause I never went beyond high school maths. :)

CBJ
EGOSOFT
EGOSOFT
Posts: 51974
Joined: Tue, 29. Apr 03, 00:56
x4

Post by CBJ » Thu, 30. Oct 03, 10:59

A lot of successful programmers are self-taught, starting out by just sitting down with the computer, a programming language and a manual, and working it out as they go along. We only had a couple of computers when I was at school (yeah, ok, so I'm getting on a bit) and little or no teaching available, so that was really the only option. College courses are good way to get started now, but as with most things you need to spend time actually using what you've learned before it really sinks in.

Once you can program in one language, the others come much more easily because most of the concepts are pretty similar even if the words change. Once you've got the hang of Perl you should be able to transfer your knowledge.

Arcus
Posts: 621
Joined: Sat, 12. Apr 03, 14:35

Post by Arcus » Thu, 30. Oct 03, 20:22

This was my first program :D it's in C++ of course :), I wrote it after many hours of reading the tutorial. I remember that i was very happy when i finished it :D. If you input a too big number to the LR variable, runtime stack overflow occurs.

Code: Select all

#include <iostream.h>

int Funct1(char In1[50],int LR, int Nr)
{
	cout<<In1;
	if (LR==0)
		cout<<" - Is going to be printed "<<Nr<<" times.\n"<<"1. ";
	else if (LR>1)
	{
		cout<<endl<<Nr<<". ";
		Funct1(In1,LR-1,Nr+1);
	}
	return 0;
}

int main() 
{
	char Str1[50];
	int LR;
	cout<<"Input some text: ";
	cin.getline(Str1,50,'\n');
	cout<<"How many times do you want the text to be repeated: ";
	cin>>LR;
	cout<<endl;
	Funct1(Str1,0,LR);
	Funct1(Str1,LR,2);
	return 0;
}
oh them joyful parasites

-TD-13-
Posts: 3172
Joined: Wed, 6. Nov 02, 20:31
x3

Post by -TD-13- » Thu, 30. Oct 03, 21:36

pjknibbs wrote:TD, you need to edit your code--in the actual code block you have cin>>a, not cin>>number! The code you posted there (a) won't compile because the variable "number" doesn't exist and (b) would give ambiguous results if it DID compile...
Thanks for pointing that out. At first I starting using number, but then I switced to a, so that it would be more like pointer88's code. Fixed. :)

-TD-13-
Posts: 3172
Joined: Wed, 6. Nov 02, 20:31
x3

Post by -TD-13- » Thu, 30. Oct 03, 22:00

JadeNova wrote:Where do you guys learn all this stuff, we never had these options when I was in College. :(

I just finished HTML and have begun PERL and it's driving me crazy. I already have a job so I'm doing it through evening classes.

I'm having to take additional classes just for the maths cause I never went beyond high school maths. :)
Suprisingly, I didn't learn it in college. (not that far yet!) I took C++ for 2 terms at my High School. It was pretty cool and we had a really awsome teacher who tried to teach us everything so that we could make some cool C++ video games and be far ahead when we got into college. This year I will be competing in High school C++ competitions at the state, and (hopefully!!!) national level. We are offered C++ (2 terms), Java, (3 terms, including an AP course), HTML (1 term), Visual Basic (1 term), and although not a programming language, Cadd (1 term). I am still taking the java clasess though, not quite done with them yet.


Oh, and I'll see if I can get some of my C++ games posted up on here, along with the source code. Hey pointer88, did you get your problem fixed? I just remember that it has to be right smack on your hard drive and the folder has to be called TC. Its been a while, so I can't remember how to fix it exactly.

Post Reply

Return to “Off Topic English”