958 Posted Topics
Re: 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. | |
Re: 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] | |
Re: [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. | |
Re: This is most of the general containers in C++: [url]http://www.cplusplus.com/reference/stl/[/url] Stack is sort of useless, for this. | |
Re: uhmm.. No. Learn to code, or at least use a search engine. | |
Re: [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 … | |
Re: Windows Console stuff(wincon.h) [icode]SetConsoleTitle("name");[/icode] | |
Re: 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. | |
Re: 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 <= | |
| |
Re: 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 … | |
Re: 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. | |
Re: 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]. | |
Re: 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. | |
Re: 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? | |
Re: 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). | |
Re: [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. … | |
Re: getline as Yiuca said. Never use macros like that. [icode]template <typename T> void input_cin(T variable);[/icode] | |
Re: Why bother posting if you mark them solved two minutes latter? | |
Re: Or use istringstream instead of atoi(). Just hope that there is a position after line Weapon_Damage. | |
Re: 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. | |
Re: 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] | |
Re: 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. | |
Re: 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); … | |
Re: Like [icode]MyStringClass object = const char *;[/icode]? You'd just simply overload it. | |
Re: 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. | |
Re: It goes from C, to asm mnemonic, to machine. [url]http://www.degraeve.com/reference/asciitable.php[/url] | |
Re: It can return all sorts of things. So does Google. | |
Re: It's to late, a lot of business are out; due to shipping expenses. | |
Re: Substring parts out to istringstream to get the values, start adding the seconds up, get difference from Jan 1, 1970 UTC | |
Re: Depends on how realistic you'd want to go, and how abstract your design is, for the physics engine. | |
Re: [url="http://www.cplusplus.com/reference/iostream/ifstream/"]C++'s ifstream[/url] | |
![]() | Re: Have you ran through the code till this occurred? And actual code is nice, too. |
Re: Did you declare unroll? Do you have the error log? Did you even bother to read the forum rules; that you have violated? | |
Re: 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. | |
Re: Have you even tracked the code till it freezed, and then evaluated it? | |
Re: What's the question??? Do you even know how to program in C++? That would be the first step towards doing anything. | |
| |
Re: [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 … | |
Re: 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(). | |
Re: 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 | |
| |
Re: 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 … | |
Re: 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. | |
Re: [URL="http://www.cplusplus.com/reference/iostream/ifstream/"]ifstream[/URL] [URL="http://www.cplusplus.com/reference/iostream/ofstream/"]ofstream[/URL] |
The End.