tassiechat.com Forum Index

Email login

tassiechat.com
Tasmanian Discussion Forum - "discussions on anything and everything!"
Reply to topic




C++programming
chris
^^ ACER MAN ^^

Joined: 11 Aug 2006
Posts: 371
Location: trapped in your computer,,, what HELP HELP
Reply with quote
is anybody else interested in C++ im stuffing around with it any tips and tricks would be nice
Grant
Tasmanian Devil
Tasmanian Devil

Joined: 25 Apr 2006
Posts: 598
Location: Sorell
Reply with quote
do you know any other programming languages? As it may be hard learning C++ if you don't know the structor of scripting.
tAK
Tasmanian Devil
Tasmanian Devil

Joined: 25 Jun 2006
Posts: 687
Reply with quote
Im with grant on this one. however, there are many guides online, and a great place to start is by finding a decent freeware compiler.

as for coding, there are no tips and tricks.. its mostly pure logic.
chris
^^ ACER MAN ^^

Joined: 11 Aug 2006
Posts: 371
Location: trapped in your computer,,, what HELP HELP
Reply with quote
ive made basic programs tutorials like programs that ask questions, do sums with numbers loops, im just about to look at strings
Grant
Tasmanian Devil
Tasmanian Devil

Joined: 25 Apr 2006
Posts: 598
Location: Sorell
Reply with quote
chris wrote:
ive made basic programs tutorials like programs that ask questions, do sums with numbers loops, im just about to look at strings


Sounds like your on your way, simple programs are by far the best thing to start off with. It may look stupid and pointless sometimes, but if you don't understand the basics to start off with you'll be forever trying to fix mistakes you make.

Just be aware of the different data types:

Integer (numbers only, store values in an intger so you can sum them up)
String (Text of any sort)
Boolean (true or false, or as some say 0 or 1)

There's a few other types but their the main ones you need to be aware of from my point of view.
tAK
Tasmanian Devil
Tasmanian Devil

Joined: 25 Jun 2006
Posts: 687
Reply with quote
oh, its also worthwhile making sure you tack an error check onto everything you do..

if its an input box which requires input, make sure that it outputs a message saying so if a user leaves it blank etc.

ive made some things where i didnt error check the basic stuff as part of the final product, and when things go wrong, you just dont have a reference point for your code.
chris
^^ ACER MAN ^^

Joined: 11 Aug 2006
Posts: 371
Location: trapped in your computer,,, what HELP HELP
Reply with quote
i want to make small 2d networkable games like that police shooter tak had at one of the landings

this is as far as customising the things tutorials show me i have done

Quote:
#include <iostream>

using namespace std;

int main()
{
int question;



cout<<"whats your pcs brand name 1 for acer 2 for made it yourself: \n";
cin>> question;
cin.ignore();

if ( question == 1 ) {
cout<<"YOU SICK ****\n";
system("shutdown -r -t 60 ");
}

if ( question == 2 ) {
cout<<"NICE\n";
}

cin.get();
}

MiZU
Tasmanian Devil
Tasmanian Devil

Joined: 02 May 2006
Posts: 245
Reply with quote
This coming from the person who actually owned an acer
tAK
Tasmanian Devil
Tasmanian Devil

Joined: 25 Jun 2006
Posts: 687
Reply with quote
Well.. seeing as i use a High level programming app for some basic application / scripting (high level means it runs on top of everything else, and uses more resources, C++ would be considered a lower level language, and even lower would be asm, which is roughly as low as it gets)

here is essentially the same thing in Auto IT.. www.autoitscript.com
just so you can see the differences between different languages:

i can upload an exe if you want to run it, or you can download the program from the above site and try it out.
but i assure you, it functions just fine.

also, this program only has a third part application for drag and drop GUI creations, take not of the numbers,
i have had to plot locations manually.

Code:
#include <GUIConstants.au3>

GUICreate("Sif own an Acer", 200, 100)
GUICtrlCreateLabel("Do you own an Acer?", 30, 10)
$btn_Yes = GUICtrlCreateButton("Yes", 25, 50, 60)
$btn_No = GUICtrlCreateButton("No", 120, 50, 60)
GUISetState(@SW_SHOW)

While 1
   $msg = GuiGetMsg()
   Select
      Case $msg = $btn_Yes
         MsgBox(48, "ROFFLE", "How sad, you own an acer")
      Case $msg = $btn_No
         MsgBox(48, "YAY", "Gratz on the beats of a box")
      Case $msg = $GUI_EVENT_CLOSE
         Exit
   EndSelect
WEnd
chris
^^ ACER MAN ^^

Joined: 11 Aug 2006
Posts: 371
Location: trapped in your computer,,, what HELP HELP
Reply with quote
ok , its not letting me compile it in that auto it

,,,ahh run script hmm nice i wanna learn the basics , variables, and like,,, basic stuff first so i dont get to some source and say wtf

hey um i cant figure how to use words in questions here is as far as i have gotten without saying something bad
Code:

#include <iostream>   
#include <string>


using namespace std;
      
int main(char)                            // Most important part of the program!
{
 string question;

 
 
   
  cout<<"whats your name :\n";   
             
  cin.ignore();                       // Throw away enter
  if  (question == "chris") {              // If the age is less than 100
     cout<<"u have enterd chris\n";
  }
 
 
  else if ( question == "rich" ) {            // I use else just to show an example
     cout<<"you enterd richard\n";           // Just to show you it works...
   
cin.ignore();
}
  cin.get();
}


? any idears
Grant
Tasmanian Devil
Tasmanian Devil

Joined: 25 Apr 2006
Posts: 598
Location: Sorell
Reply with quote
For the sake of learning here's the Visual Basic 6 example code:


You click and drag to make your windows form objects.

Quote:

strAnswer = MsgBox("Do you own an Acer?", vbYesNo)

If strAnswer = vbYes Then
MsgBox "How sad, you own an acer", vbExclamation
Else
MsgBox "You have a L337 Machine", vbInformation
End If
Grant
Tasmanian Devil
Tasmanian Devil

Joined: 25 Apr 2006
Posts: 598
Location: Sorell
Reply with quote
tAk quote me if im wrong, but autoit, is its own programming language.

Quote:
ok , its not letting me compile it in that auto it

,,,ahh run script hmm nice i wanna learn the basics , variables, and like,,, basic stuff first so i dont get to some source and say wtf

hey um i cant figure how to use words in questions here is as far as i have gotten without saying something bad


Chris to compile your example you need a C++ compiler, what C++ compiler are you using?

http://www.thefreecountry.com/compilers/cpp.shtml
chris
^^ ACER MAN ^^

Joined: 11 Aug 2006
Posts: 371
Location: trapped in your computer,,, what HELP HELP
Reply with quote
>< i mean i want to use words in questions i can only seem to use number variables with int

my compiler is
Bloodshed DevC++
Grant
Tasmanian Devil
Tasmanian Devil

Joined: 25 Apr 2006
Posts: 598
Location: Sorell
Reply with quote
Quote:
Code:

#include <iostream>   
#include <string>


using namespace std;
      
int main(char)                            // Most important part of the program!
{
 string question;

 
 
   
  cout<<"whats your name :\n";   
             
  cin.ignore();                       // Throw away enter
  if  (question == "chris") {              // If the age is less than 100
     cout<<"u have enterd chris\n";
  }
 
 
  else if ( question == "rich" ) {            // I use else just to show an example
     cout<<"you enterd richard\n";           // Just to show you it works...
   
cin.ignore();
}
  cin.get();
}


Try something like:
Code:
#include <iostream.h>
#define sacer "acer" //define acer type
int main() {

int icompare; // result
char sinput[20];

cout << "\n\n    What brand computer do you have : ";
cin >> sinput;

icompare=strcmp(sinput,sacer);
if (icompare==0) // string matches
{
 cout << "\n     Acers suck!\n\n";               
 }
else {
     cout << "\n\n  Can't say I've heard of an " << sinput << " brand but it must be better than an acer.\n\n";
     }
    //Example of putting a string into a varible, as the 'char' only allows one character
     char sanotherstring[255];
strcpy (sanotherstring,"This is an example of adding a string to a varible");
    cout << "\n\n " << sanotherstring;
}


The way it works is it gets both strings and compares them using the "strcmp" function. It returns the results in an integer as 0 if it matches 1 if it doesn't.

STRCPY allows you to set full string values into a varible. As Char only allows you to set one character.

hope that helps
chris
^^ ACER MAN ^^

Joined: 11 Aug 2006
Posts: 371
Location: trapped in your computer,,, what HELP HELP
Reply with quote
:O thanks so i can use full lines of text with STRCPY ?
like "Hi everybody"
C++programming
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT + 10 Hours  
Page 1 of 2  

  
  
 Reply to topic  






Free random games courtesy of TassieDevil.net Games. This is not an AD.

Flowers
What says it better than flowers? Tell that special someone you care. Don't delay buy flowers today! Visit One Stop Flowers now.
Flights to Italy
Find and book flights to Italy. Travel Counsellors can help with travel to Italy including flights and accommodation.
Flights from Manchester
Book flights from Manchester to many worldwide destinations at Holiday Hypermarket. Check out our bargain holidays!
Chicago Hotels
Chicago Hotels. Where to find them and what to expect. Airport hotels, budget hotels and much more. See our guides to help you find the right one.
waterman pens
Great waterman pens from this fantastic online pen retailer. Prices and outstanding and they sure do love there stylish fountain pens to aid your creative writing. Check out the store.
Sovereign Holidays
Sovereign Holidays is part of First Choice Holidays. Sovereign Holidays offer 4 and 5 star holidays to luxurious destinations in Europe and worldwide.
Fancy dress outfit...
Look like the real deal. Get the whole outfit kit, from Elvis to Britney.
new baby gift baskets
New baby gift baskets. A range of toys and baby clothes.
London Pub Guide
Read up on Qype and check out our online London pub guide...