![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#21 |
|
Hobbyist Programmer
|
yeah... I'm dealing with that now... but it doesn't seem too hard... you juast have to specify the variable at the beggining of the code and then call it as required...
The only dullest thing to do is to memorize the integer, boolean... crap! =/ |
|
|
|
|
|
#22 |
|
Hobbyist Programmer
|
AAAAARGH!!!!
What gives? I've been learning all about variables and stuff and when I tried to make something out of what I've learned I've errors.. ![]() /*Making variables is fun
and I will have lots of fun
doing them today! So of with
the show! As a I output stupid
text using fun stuff like
variables!! :D*/
#include <iostream>
using namespace std;
int var_tex_a; //this is a dandy global variable
int >> var_tex_b; //although somewhat obsolete, in this case, this is and external variable (which doesn't seem to work)
int hello;
int main () //so this should be starting the main function...
{
int stuff; //and this is a local variable
var_tex_a = "pretty images"; //here I assign stuff for the variables...
stuff = "I made this stuff! :D";
hello = "HELLO WORLD!"
//and now I shall generate the actions for the program! :D
cout << "So this is very hard to do" /n;
cout << "seing that I'm programing for the very first time" /n;
cout << "I can now make a more complex 'Hello world thing'" /n;
cout << "but on with the dandy output:" /n;
cout << ""/;
cout << hello /n:
cout << /t /t stuff endl;
return 0;
}
//which seems not to work... how disapointing!The comments explain just what I was trying to make in each line... but I got too many errors! ![]() When I tried: /*Making variables is fun
and I will have lots of fun
doing them today! So of with
the show! As a I output stupid
text using fun stuff like
variables!! :D*/
#include <iostream>
using namespace std;
int var_tex_a; //this is a dandy global variable
int >> var_tex_b; //although somewhat obsolete, in this case, this is and external variable (which doesn't seem to work)
int hello;
int main () //so this should be starting the main function...
{
int stuff; //and this is a local variable
var_tex_a = "pretty images"; //here I assign stuff for the variables...
stuff = "I made this stuff! :D";
hello = "HELLO WORLD!"
//and now I shall generate the actions for the program! :D
cout << "So this is very hard to do" /n;
<< "seing that I'm programing for the very first time" /n;
<< "I can now make a more complex 'Hello world thing'" /n;
<< "but on with the dandy output:" /n;
<< ""/;
<< hello /n:
<< /t /t stuff endl;
return 0;
}
//which seems not to work... how disapointing!I've fiddled with the code for hours now, but I just don't see what's wrong! ![]() ![]() ![]() Sorry for bugging you with trivial questions like this one, but I figure I must learn by annoying someone... (you were just unlucky enough to be picked by me). Just look on the bright side, maybe when I become a super-programmer-type-guy I can help you instead! ![]()
__________________
PORTUGALPORTUGA PORTUGALPORTUGA PORTUGALPORTUGA PORTUGALPORTUGA PORTUGALPORTUGA |
|
|
|
|
|
#23 | |
|
Newbie
Join Date: Jan 2005
Posts: 2
Rep Power: 0
![]() |
/*Making variables is fun
and I will have lots of fun doing them today! So of with the show! As a I output stupid text using fun stuff like variables!! */#include <iostream> using namespace std; int var_tex_a; //this is a dandy global variable I really don't know what you were trying to do here, or I have never used external variables before... int >> var_tex_b; //although somewhat obsolete, in this case, this is and external variable (which doesn't seem to work) int hello; int main () //so this should be starting the main function... { int stuff; //and this is a local variable The errors might be between these lines //because int only accept numbers, assigning strings to it might result in error... var_tex_a = "pretty images"; //here I assign stuff for the variables... stuff = "I made this stuff! ";hello = "HELLO WORLD!" //and now I shall generate the actions for the program! ![]() The errors might be between these lines Ok, more errors here too, because the '\n' has to be inside the quotations.. cout << "So this is very hard to do" /n; cout << "seing that I'm programing for the very first time" /n; cout << "I can now make a more complex 'Hello world thing'" /n; cout << "but on with the dandy output:" /n; cout << ""/; cout << hello /n: cout << /t /t stuff endl; return 0; } //which seems not to work... how disapointing! This is without the errors... #include <iostream>
using namespace std;
int var_tex_a; //these are dandy global variables
int var_tex_b;
int hello;
int main () //so this should be starting the main function...
{
int stuff; //and this is a local variable
var_tex_a = 1; //here I assign stuff for the variables, and since they are integers, numbers will do...
stuff = 19;
hello = 10;
//and now I shall generate the actions for the program! :D
cout << "So this is very hard to do \n"
<< "seing that I'm programing for the very first time \n"
<< "I can now make a more complex 'Hello world thing' \n"
<< "but on with the dandy output: \n"
<< "\n"
<< hello << "\n"
<< "\t\t"<< stuff << endl";
return 0;
}Or if you wanted your program to display the text you specified... #include <iostream>
#include <string>
using namespace std;
string var_tex_a; //these are dandy global variables
string var_tex_b;
string hello;
int main () //so this should be starting the main function...
{
string stuff; //and this is a local variable
var_tex_a = "pretty images";
stuff = "i made this stuff";
hello = "HELLO WORLD";
//and now I shall generate the actions for the program! :D
cout << "So this is very hard to do \n"
<< "seing that I'm programing for the very first time \n"
<< "I can now make a more complex 'Hello world thing' \n"
<< "but on with the dandy output: \n"
<< "\n"
<< hello << "\n"
<< "\t\t"<< stuff << endl;
return 0;
}Quote:
![]() |
|
|
|
|
|
|
#24 |
|
Programming Guru
![]() Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5
![]() |
congratulations to broax for starting the longest intro threads ever.
hey broax...we eat this shit up, we love it. maybe if i hadn't just had ten beers i would be able to help you. right now i can only say random bullshit (otherwise i might say something dumb). good luck.
__________________
i put on my robe and wizard hat... Have you ever heard of Plato, Aristotle, Socrates?...Morons. |
|
|
|
|
|
#25 |
|
Hobbyist Programmer
|
no man... this ain't my intro thread!
The intro thread is the "hello" one... :p BTW, since you're driking beers tell me exactly how strong that beer is... 'cause my (german) cousin once told me that american beer is like making love on a canoo... fucking close to water! lolol How I love this one! Anyway... Osiris, thanks a lot for the code, but now I'm having problems with this (diferent code) which is: /*Why oh why can't I handle a
lot of variables!? I don't know
but I will sure try now... :D */
#include <iostream>
using namespace std;
string var_myname;
int var_num1;
int var_num2;
string var_myname = "Joao Oliveira (aka broax)"; //I didn't know I had to specify the variable type even when I'm defining it!
int var_num1 = 10;
int var_num2 = 9;
int main();
{
int total;
var_total = var_num1 + var_num2;
cout << "So let's try some more of this baisc programming stuff /n" << endl;
cout << "My name is " var_myname "and I'm " var_total "years old." << endl;
return 0;
}I think it's easy to see what I'm attempting to do... this would just output my name and my age, but (and this is the fancy part) the age would be a sum between to variables. I'm getting all sorts of errors but most of them are repeated... Also, as far as the tutorial told me, and external variable is a variable that works with other files of the program... like file_a.dfg has a variable that can also be used by file_b.dfg (that's what I understood, at least. Anyway, what kind of stupid errors have I made!?
__________________
PORTUGALPORTUGA PORTUGALPORTUGA PORTUGALPORTUGA PORTUGALPORTUGA PORTUGALPORTUGA |
|
|
|
|
|
#26 |
|
Programmer
Join Date: Jan 2005
Location: Bayamon, Puerto Rico
Posts: 71
Rep Power: 4
![]() |
Hey Broax hi again I think your error is when u declare the variable total or var total... this is your code
int total; var_total = var_num1 + var_num2; int var_total; var_total = var_num1 + var_num2; hope this info solve your prob... didnt compile it... codetaino Edited: sorry also when you assign a value to the variables you dont have to write the type of the variable again... do one of two things... or delete the variable declarations without the assignments... example int var_num1; and leave the one int var_num1 = 10; that will do the two tasks declare the variable and initialize (or assign a value) or just erase the variable type on the assignments example int var_num1 = 10; changed to var_num1=10; without the int codetaino
__________________
"God bless u all" :) Last edited by codetaino; Jan 19th, 2005 at 10:35 PM. |
|
|
|
|
|
#27 |
|
Hobbyist Programmer
|
Yes, that was a really really stupid mistake by me, but I'm getting lots of errors that I don't understand... Like:
Line: 13 - syntax error before '{' token Line: 15 - ISO C++ forbids declaration of ' var_total' with no type Line: 17 - syntax error before '<<' token Line: 18 - syntax error before '<<' token Anyway, when I type <b>int something = 12</b> it works just fine, but if I try to declare the variable and assign a value to it in diferent lines I get the following error: Line: 12 - redefenition of 'std::string var_myname' Line: 08 - 'std::string var_myname' previously declared here Wasn't it suppose to work anyway? Anyway, the reason I wasn't able to reply yesterday, it 'cause I had to do some paperwork and some stuff, and now I'm a FireFighter! ![]() ![]() ![]() ![]() ![]() I just need some time so the process gets through (here in portugal redtape is a huuuge problem) but I think that in, like... 2 weeks I'll start! ![]() ![]() ![]() I can't wait! ![]() ![]() ![]() ![]() ![]() ![]() EDIT: I managed to fix one of the errors, I seem to oversee basic strings and I missed a naughty semicolon on the <b>int main()</b> line... which takes care of error: Line: 13 - syntax error before '{' token I also removed the <b>int var_total</b> declaration for the same strange reason I removed the other declarations... I really don't get that, I thought that I was supposed to declare it be for definning it... Does anyone care to explain to me please? EDIT: NEW AMAZING UPDATE: I forgot how important the misterious <b><<</b> can be, so I just added a couple of these before the variable output and the code now acts like a charm! ![]() Final code is: /*Why oh why can't I handle a
lot of variables!? I don't know
but I will sure try now... :D */
#include <iostream>
using namespace std;
string var_myname = "Joao Oliveira (aka broax)";
int var_num1 = 10;
int var_num2 = 9;
int main()
{
int var_total = var_num1 + var_num2;
cout << "So let's try some more of this baisc programming stuff \n" << endl;
cout << "My name is " << var_myname << "and I'm " << var_total << "years old." << endl;
return 0;
}Hurray for my amazing programming skills!! Anyway, I'd still appreciate very much an explanation why I get an error everytime I try to declare and assign values to a string in two lines of code, as follows: string pretty_little_variable; pretty_little_variable = "I'll beat the shit out of bill gate's pu*** OS! :D"; If I want it to work I must do: string pretty_little_variable = "I'll beat the shit out of bill gate's pu*** OS!:D"; Is this normal? Should it happen? Is it something that I miss-learned? It seems to be connected to the <b>std</b> thing, so maybe it's just worked on the older <ioheaders.h> thing. Thanks for the attention... ![]()
__________________
PORTUGALPORTUGA PORTUGALPORTUGA PORTUGALPORTUGA PORTUGALPORTUGA PORTUGALPORTUGA Last edited by Broax; Jan 21st, 2005 at 5:41 AM. |
|
|
|
|
|
#28 |
|
Programming Guru
![]() Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5
![]() |
beer
as far as the strength of the beer...it really depends where you live. (by state i mean) but it really doesn't matter after about 12-18 or so. i like bud light, which is usally 5% alcohol usually. although i HAVE BEEN to germany and their beer is cool too. right now though i'm drinking "steel reserve" and it's 6%. and the "fucking ner water" joke is for coors light here. :-)
__________________
i put on my robe and wizard hat... Have you ever heard of Plato, Aristotle, Socrates?...Morons. |
|
|
|
|
|
#29 |
|
Hobbyist Programmer
|
yeah... that's about portuguease beer too...
![]() Nothing worse then piss-strong beer:eek:
__________________
PORTUGALPORTUGA PORTUGALPORTUGA PORTUGALPORTUGA PORTUGALPORTUGA PORTUGALPORTUGA |
|
|
|
|
|
#30 | |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Quote:
string pretty_little_variable;
int main {
pretty_little_variable = "I'll beat the shit out of bill gate's pu*** OS! :D";
.
.
.
} |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|