958 Posted Topics

Member Avatar for alfred210989

Have you learned about practical use of loops to shorten(even speed up) code, or passing parameters instead of leaving things out in the global nowhere.

Member Avatar for alfred210989
0
1K
Member Avatar for Phil++

Convert the string to evaluate to lower case, then use it. I prefer if-else statments, of stings for input. For ASCII In a loop of string size: [icode]if (is upper case(91< && 64>)) then swap_case()[/icode] Swap function: [icode]function swap_case(&character) character XOR 32[/icode]

Member Avatar for grumpier
0
117
Member Avatar for dparas

[url]http://en.wikipedia.org/wiki/Permutation[/url] [url]http://regentsprep.org/regents/Math/permut/Lperm.htm[/url] One way, start at zero and increase(i.e. [icode]++variable;[/icode]), till you reaching the target.

Member Avatar for ArkM
0
1K
Member Avatar for ace_dman

This is most of the general containers in C++: [url]http://www.cplusplus.com/reference/stl/[/url] Stack is sort of useless, for this.

Member Avatar for ace_man
0
2K
Member Avatar for vikashkumar051
Member Avatar for serkan sendur
Member Avatar for HarryGabriel91

[QUOTE=StuXYZ;776770] The first is that the planet and the start are going to orbit each other. The second is that the planet is going to escape on a hyperbolic or parabolic orbit. You can test the possiblity of either (a) or (b) by calculating the total energy required to separate …

Member Avatar for MosaicFuneral
0
143
Member Avatar for Phil++
Member Avatar for Phil++
0
113
Member Avatar for massivefermion
Member Avatar for Phil++

So you want a program that generates a script, then executes a program that will interpret the script? You need to work on how you ask things. Just like how your title has nothing to describe your predicament.

Member Avatar for VernonDozier
0
110
Member Avatar for winrawr

You tried to screw with a third element, but you only have the array set to [2]. It's also [icode]i < 3[/icode] not <=

Member Avatar for Freaky_Chris
0
140
Member Avatar for bluebird
Member Avatar for bluebird
0
103
Member Avatar for AdRock

You should split up all the tasks into separate functions. All of it should be part of class. The file handling would probably look like this. Unless you're concerned about massive files.. [code] if(file.is_open) { while(getline(file, str)) { lines.push_back(str); } file.close(); }[/code] You now have the contents. Time to just …

Member Avatar for BevoX
0
161
Member Avatar for Phil++

At first it sounds like you want a script interpreter, then a code generator; then a paradox almost or just weirdly written statements. Interpreter = easy enough. Code Generator = bit of challenge. Compiler = lot of experience, or maybe get a degree in CS.

Member Avatar for u8sand
0
168
Member Avatar for Phil++

One, site rule, CodeTags!! Two, use functions [icode]void FileHandler::open(const char *name, const int &mode);[/icode]. Three, don't bother with eof(). Try, [icode]while(getline(file, line))[/icode].

Member Avatar for Phil++
0
151
Member Avatar for The Dude

I thought it was a he? 0.o That was cool. Never as good as [url="http://www.youtube.com/watch?v=dt-IY7GZe3c&feature=related"]Yehudi Menuhin[/url], though.

Member Avatar for GrimJack
0
38
Member Avatar for guest7

You mean [icode]varible++;[/icode], or [icode]variable += 1;[/icode]? Perhaps you could go to the extreme of doing it with bit operators(I have for fun), or using the inline assembler to do it. So many options, but which is right for you?

Member Avatar for MosaicFuneral
0
449
Member Avatar for winrawr
Member Avatar for #include<James>

Do not declare things in a loop. Do it all before hand. I think you're confusing std::string with a C style string, because you can just append things to the end without dealing with [icode][][/icode]. Unless you plan on allocating them(no need with STL containers like vector).

Member Avatar for Murtan
0
132
Member Avatar for serhannn

[QUOTE=skatamatic;775375][code=cplusplus] ifstream inFile; vector<string> data; inFile.open("File.txt"); while (!inFile.eof()) { string sString = inFile.getline(); data.push_back(sString); } [/code][/QUOTE] Don't bother with eof(), and don't put declarations in loops. Simplified: [code]ifstream file("name"); vector<string> lines; string str; if(file.is_open()) { while(getline(file, str)) { lines.push_back(str); } file.close(); } else { failed. set error events, logs, etc. …

Member Avatar for serhannn
0
262
Member Avatar for Phil++

getline as Yiuca said. Never use macros like that. [icode]template <typename T> void input_cin(T variable);[/icode]

Member Avatar for minas1
0
118
Member Avatar for tomtetlaw
Member Avatar for tomtetlaw
0
92
Member Avatar for Gekitatsu

Or use istringstream instead of atoi(). Just hope that there is a position after line Weapon_Damage.

Member Avatar for Yiuca
0
177
Member Avatar for learning_prog

firstPerson, more important is Code Tags. To use command prompt, go to Start->Programs->Accessories, then use [icode]cd[/icode] to navigate to the file and then type the name of the program.

Member Avatar for John A
0
129
Member Avatar for heimdhal

Quick nickpicks: I don't see a destructor, and keep rules[] private. Normally variable names are lowercase. Why are you assigning it zero? [icode]Rule *rules; rules = new Rule [200]; delete [] rules;[/icode]

Member Avatar for heimdhal
0
105
Member Avatar for Bladtman242

Don't use gotos, there is [icode]break;[/icode] and things called functions. Why are you closing it if it doesn't open? Re-write it.

Member Avatar for Bladtman242
0
117
Member Avatar for David2x
Member Avatar for michaelmorris

That's some dangerous looking code. [code]class B { private: vector<string> array; public: void method_add(int &stuff, int more); }; void B::method_add(int &stuff, int more) { stuff += more; }[/code] [code]class A { private: B objectB; public: void do_something(void); }; void A::do_something(void) { int a = 7, b = 9; objectB.method_add(a, b); …

Member Avatar for michaelmorris
0
164
Member Avatar for u8sand

Like [icode]MyStringClass object = const char *;[/icode]? You'd just simply overload it.

Member Avatar for u8sand
0
99
Member Avatar for Alex_

It's <iostream> not <iostream.h>, try <string> not the old C way. By using string you can simplify it and create an easier to follow flow of code. [url]http://www.cplusplus.com/reference/string/string/[/url] And by the way, main() must return zero.

Member Avatar for Alex_
0
152
Member Avatar for serkan sendur

It goes from C, to asm mnemonic, to machine. [url]http://www.degraeve.com/reference/asciitable.php[/url]

Member Avatar for serkan sendur
0
213
Member Avatar for harryoma
Member Avatar for vmanes
Member Avatar for Dave Sinkula
0
249
Member Avatar for aramakri

Substring parts out to istringstream to get the values, start adding the seconds up, get difference from Jan 1, 1970 UTC

Member Avatar for Murtan
0
58
Member Avatar for mrnutty

Depends on how realistic you'd want to go, and how abstract your design is, for the physics engine.

Member Avatar for mrnutty
0
143
Member Avatar for Crul
Member Avatar for xyzt

[url="http://www.cplusplus.com/reference/iostream/ifstream/"]C++'s ifstream[/url]

Member Avatar for Ancient Dragon
0
120
Member Avatar for RenFromPenn
Member Avatar for MosaicFuneral
0
231
Member Avatar for guest7

Did you declare unroll? Do you have the error log? Did you even bother to read the forum rules; that you have violated?

Member Avatar for Comatose
0
142
Member Avatar for harryoma

It's a semicolon, not a comma. You should also use a loop, not leaving it unrolled like that, especially if you decide to expand the array size latter.

Member Avatar for harryoma
0
93
Member Avatar for amerninja2
Member Avatar for vandenzergen

What's the question??? Do you even know how to program in C++? That would be the first step towards doing anything.

Member Avatar for vandenzergen
0
116
Member Avatar for cppnewb
Member Avatar for cppnewb
0
102
Member Avatar for scias23

[QUOTE=scias23;768593]help here again... if i enter AaBbCc the output should be CcBbAa or cCbBaA.. but the output appears cbaCBA.. help!!! heres the code.. [ICODE] #include<iostream.h> #include<conio.h> #include<string.h> #include<stdio.h> #include<search.h> //int joke(const void* x,const void* y); void main() { clrscr(); char a[100],temp; cout<<"Enter string: "; cin>>a; for(int i=(strlen(a)-1);i>=0;i--) cout<<a[i]; cout<<"\n\nLETTERS IN …

Member Avatar for scias23
0
2K
Member Avatar for mrnutty

Or just: [code] ifstream file("name"); sting str; if(file.is_open()) { file >> str; file.close(); }[/code] If you're parsing a string, then possibly substring it and use istringstream to place it into an int. You'd probably also have to check the string size(counting till non-num found), and compare it to string.max_size().

Member Avatar for VernonDozier
0
151
Member Avatar for cohen

Oh no, there might be to much religious reference here and a mother at school might see her kid on it and have to sue Daniweb. lol

Member Avatar for stephen84s
0
127
Member Avatar for sillyboy
Member Avatar for brandmantra
0
272
Member Avatar for beast0000

Site rules, "CODE TAGS!" The usual structure I suggest often, to avoid the whole emergency bail out thing. [code]file open if(file.is_open()) { do stuff here; file.close(); } else { cout << "Error!"; }[/code] You probably should place those loops in a function too. Where is [icode]i[/icode] declared? You need to …

Member Avatar for MosaicFuneral
0
80
Member Avatar for cam875

If it can't open it then why do you continue to use it afterward? [icode]file open if(is open) { do stuff close } else { print "Error" }[/icode] You're also missing a return.

Member Avatar for cikara21
0
96
Member Avatar for jugnu

[URL="http://www.cplusplus.com/reference/iostream/ifstream/"]ifstream[/URL] [URL="http://www.cplusplus.com/reference/iostream/ofstream/"]ofstream[/URL]

Member Avatar for MosaicFuneral
0
113

The End.