2,712 Posted Topics

Member Avatar for chamnab

You need to define what exactly you mean by limit. For example what should happen in the sixth character? Should the program just go with the first five character or should the program output an error message if more that 5 character is entered or should the program enable the …

Member Avatar for jonsca
0
96
Member Avatar for DaniwebOS

The first thing I see is this : [code] int main() { //called functions void userData(string studentName, int numOfClasses, char letterGrade); double calData(int totalPoints, int numOfClasses); void displayData(string studentName,char letterGrade, double gpa); getch(); return 0; } [/code] which is wrong and should be this : [code] int main() { //called …

Member Avatar for DaniwebOS
0
131
Member Avatar for skips
Member Avatar for Red Goose
0
131
Member Avatar for becool007

>>[B]Note: Im planning on using this with a Message box[/B] If so then you will need to convert the variable to a string if its not already. A handy tool is to use something like the following : [code] template<typename ReturnType, typename InputType> ReturnType convertTo(const InputType& input){ std::stringstream stream; //#include …

Member Avatar for ravenous
0
113
Member Avatar for lochnessmonster

[icode]struct car cobalt [/icode]. car is not a pointer. I believe you want something like so, [icode] struct car cobalt[23] [/icode]. In that case you could use the same notation as for regular arrays. For class object there is a special pointer operator[icode]cobalt->gas[/icode]. Notice the "->" operator. For class objects …

Member Avatar for VernonDozier
0
147
Member Avatar for Nandomo

Just note( I may be wrong but its worth thinking about ): They will teach you theoretically that linked list are fast for insertion in the front, middle, and end of the list. Fast in terms of theoretical comparison of big-omega. While theoretically this is true, in practice, you will …

Member Avatar for Nandomo
0
96
Member Avatar for MultipleMoney

A suggestion is to make a get() function that checks for errors, for example : [code] template<typename InputType> InputType getType(){ InputType var = InputType(); while( ! (cin >> var) ){ cout << "\nInput failed...try again : "; //print error message if failed cin.clear(); //clear the error bits while(cin.get() != '\n') …

Member Avatar for MultipleMoney
0
1K
Member Avatar for gregarion
Member Avatar for deltamaster
0
527
Member Avatar for CrazyPixel
Member Avatar for Jsplinter
Member Avatar for alex55

[QUOTE=alex55;1460923]1 is consistent throughout the entire program in all the arrays would that still affect it?[/QUOTE] If you ever do [I]monthAverage[0], monthSum[0], or monthInput[0] [/I]it will be garbage! But your problem is with your for loop condition. In all of your for loop you use [I]i <= someVariable[/I]. The problematic …

Member Avatar for alex55
0
123
Member Avatar for ticktock

Use action listener for each unique button category. For example, just a simple idea is to make a action listener for the numbers and have a actin listener for the functions. Here is a non-compiled on the spot simple example : [code] class Calculator extends JPanel{ private ArrayList<JButton> numbers; private …

Member Avatar for ticktock
0
670
Member Avatar for lochnessmonster

I don't know any sites but [URL="http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=function+pointer+C%2B%2B"]google[/URL] does, and it spat out [URL="http://www.newty.de/fpt/index.html"]this[/URL] site first. Try it.

Member Avatar for mike_2000_17
0
77
Member Avatar for Transcendent
Member Avatar for caut_baia

Are you really trying to use meta-programming to create an array of site t?

Member Avatar for caut_baia
0
98
Member Avatar for NathanOliver

To polish it, you can combine the words[] and numbers[] into one std::pair<string,int>; And your search in GetNumber could be just, [icode]numbers[ words.find_first_of(number) ][/icode], but be careful about error checking. And make the parameters const-reference. This code [code] std::string tempString; size_t size = sentence.size(); for (size_t i = 0; i …

Member Avatar for vijayan121
0
167
Member Avatar for lochnessmonster

Depending on the exact content, the node class might have to be-friend the list class in the second case, while in the first one it does not.

Member Avatar for mrnutty
0
61
Member Avatar for aznlitomik3

Two options: 1) You can output 2 decimal places 2) You can change the actual precision of variable to 2 decimal places For option number 1, here is an example : [icode]float f = 1.23456f; cout.precision(3); cout << f;[/icode] and for option number 2, here is an example : [code] …

Member Avatar for VernonDozier
0
225
Member Avatar for alonewolf23

You have to find the start and end position of the quoted text. In C++, using std::string you can use the following call to find the first quote position [icode]stringVariable.find_first_of("\"")//find the first '"' [/icode]. So you can use "\"" to represent a quote character.

Member Avatar for WaltP
0
274
Member Avatar for thisischris
Member Avatar for mrnutty
0
107
Member Avatar for MasterGberry

Just an example : [code] #include <iostream> #include <vector> using namespace std; struct Person{ int age_; float gpa_; Person(int age = 0, float gpa = 0.0f) : age_(age), gpa_(gpa) {} }; ostream& operator << (ostream& stream, const Person& p){ return stream << "[" << p.age_ << "," << p.gpa_ << …

Member Avatar for MasterGberry
0
101
Member Avatar for gomathi007

[URL="http://oopweb.com/Assembly/Documents/SPIM/Volume/Floating%20Point%20Instructions.htm"]http://oopweb.com/Assembly/Documents/SPIM/Volume/Floating%20Point%20Instructions.htm[/URL] It basically converts a single precision into double precision and puts it in an appropriate register.

Member Avatar for mrnutty
-1
49
Member Avatar for Mayank23
Member Avatar for alaa sam
0
109
Member Avatar for LevyDee

Yes, use delete when new is used to allocate that memory, and forgot about malloc and free if you are in C++ world. Check here for more info. [URL="http://www.parashift.com/c++-faq-lite/freestore-mgmt.html#faq-16.3"]http://www.parashift.com/c++-faq-lite/freestore-mgmt.html#faq-16.3[/URL]

Member Avatar for nndung179
0
231
Member Avatar for MasterGberry

You can't shuffle map. A Quote from C++ Reference [QUOTE]Internally, map containers keep their elements ordered by their keys from lower to higher , therefore begin returns the element with the lowest key value in the map[/QUOTE] so you just made a poor choice in data structure. I suggest you …

Member Avatar for MasterGberry
0
1K
Member Avatar for ragebunny

Well what do you intend to use the heightmap for? One use for them is to create a terrain based on the heightmap. For example, you would use the heightmap values to map the height of the plane at a given point.

Member Avatar for PsychoLogic
0
113
Member Avatar for livinFuture

To get what you want, you need to read it as a string, and then parse the string. Some example : [code] string str; cin >> str; //for example assume user enters 11:22:33 string::size_type hourEndPosition = str.find_first_of(":"); int hours = atoi( str.substr(0,hourEndPosition) ); string::size_type minuteEndPosition = str.find_first_of(hourEndPosition+1,minuteEndPosition); int minutes = …

Member Avatar for mrnutty
0
12K
Member Avatar for pucivogel

Just a wild guess at what you want but a negative number can be represented in a string simply by the negation operator like so : [icode] string negativeFive = "-5" [/icode]. Then if you want to convert it back, then you can check if [icode]negativeFive[0] == '-'[/icode] and if …

Member Avatar for mrnutty
0
82
Member Avatar for pucivogel
Member Avatar for Moschops
0
135
Member Avatar for rmbrown09

I think you can have an algorithm that does this in constant time. I'm not sure why you have so much code[ didn't bother to look ]. Try to formulate a formula for a given range.

Member Avatar for mrnutty
0
621
Member Avatar for jfunchio

[QUOTE=Fbody;1454559]??? I'm glad you know what that means. It just looks like spam to me... I'm tempted to report it for not being written in English.[/QUOTE] [ICODE]这么明显的错误你都发现不了?你到底是不是C++编程人员[/ICODE] is in Chinese and maps to [ICODE]Such an obvious mistake you can not find it? You in the end is not C + …

Member Avatar for Fbody
0
355
Member Avatar for pucivogel

>>[B]error C2057: expected constant expression[/B] corresponds withs this[icode]double term[sizeofpolynom];[/icode]. The reason being is [i]that sizeofpolynom[/i] isn't known at compile time. Because the user can pass it anything. So to solver this there is a couple of things you can do, but the easiest way that I suggest is to use …

Member Avatar for pucivogel
0
154
Member Avatar for Duki

@Fbody: I think that statement you posted is intentional. I have a feeling that it uses return values to signify success or not. So the if statement checks if the return value is a success or a fail. A fail probably returns 0.

Member Avatar for Duki
0
649
Member Avatar for martin11ph

Just create a std::map with all of the reserved words, and check for them using that. And for your post script, unique just means there is only one of.

Member Avatar for mrnutty
0
154
Member Avatar for somshridhar

You are using depreciated header files, take out the [b].h[/b]. And [b] int main [/b] is in these days. And you need to either use fully qualified name or use the using declaration. [code] #include<string> #include<iostream> int main(){ using namespace std; string str = "My name is shridhar"; cout<<"What is …

Member Avatar for kernel>panic
0
4K
Member Avatar for Nandomo

I think something like this should work : [code] #include <fstream> #include <iostream> #include <string> #include "CommonFunctions.h" using namespace std; struct BitmapInfo{ unsigned char id[2]; unsigned char size[4]; unsigned char unUsed[4]; unsigned char pixelOffset[4]; unsigned char bytesInDIBHeader[4]; unsigned char width[4]; unsigned char height[4]; BitmapInfo() : id(), size(),unUsed(),pixelOffset(),bytesInDIBHeader(),width(),height() {} }; int …

Member Avatar for Moschops
0
129
Member Avatar for curbster

You want something like this : [code] int getIntGrade(char letter){ if(letter == 'A' || letter == 'a') return 95; if(letter == 'B' || letter == 'b') return 85; //and so on } [/code] And if you want to go the other way it would look something like this. [code] char …

Member Avatar for curbster
0
1K
Member Avatar for cppgangster
Member Avatar for amr321

Programming is logical. So you need to train your self how to think logically. Some people compare programming with math because they both require perfect logic. So my suggestion is to change your mind of thought. Train yourself to think more logically. One way to do this, is to do …

Member Avatar for rusl07cl08
-1
648
Member Avatar for TheWolverine

Just looking at your main, specifically this part : [code] mySolver.setMathematicalMethod( pointerToMathematicalMethod ); mySolver.solve(); [/code] intuitively, I would expect [i] mySolver.solve()[/i] just delegate the job to the mathMaticalMethod. So what I am trying to say is that your computeValue(...) function in your mySolver doesn't make sense to me. It should …

Member Avatar for TheWolverine
0
95
Member Avatar for Phil++

[QUOTE]Is set theory like arrays in C# and C++ for example?[/QUOTE] No no where close. Set theory is a branch of mathematics. Check [URL="http://en.wikipedia.org/wiki/Set_theory"]here[/URL] for more info.

Member Avatar for mrnutty
0
84
Member Avatar for happygeek
Member Avatar for Rimojenkins

Print out your "input" and see if its correctly formatted. Make sure you account for the spaces. Have you learned about classes and structures? >>[QUOTE] I don't want to cheat. This is my major and I have a passion for it, but I can not find this answer in my …

Member Avatar for Rimojenkins
0
116
Member Avatar for ana_1234

There is some problems with your code, right now I'm too lazy to point them out and try to explain it all. Instead I will give you a push in the right direction to achieve what you want to do. First you want to make use of std::string and std::vector. …

Member Avatar for griswolf
0
91
Member Avatar for atticusr5
Member Avatar for MasterGberry

Are you interpreting the data in [i]std::vector<char>[/i] as big-endian or little-endian? To reverse the process you an just shift right and use the bitwise and operator. So just to get this straight, you have a std::vector<char> full of whole unsigned digits correct? And if the user wants to read say …

Member Avatar for MasterGberry
0
214
Member Avatar for Nandomo

Check out [URL="http://en.wikipedia.org/wiki/BMP_file_format"]wiki_bitmap[/URL]. It has good explanation of how bitmaps are formatted. From there you can determine how to read the width/height, and the starting offset of where the actual pixels starts from.

Member Avatar for Nandomo
0
132
Member Avatar for rebellion346

As said earlier, you aren't using the template correctly. In your "SetName", if a template instantiation is made of type double, then you will have a compiler error, because you can't assign a double to a string.

Member Avatar for mike_2000_17
0
124
Member Avatar for TailsTheFox

Are you using solely C++. What platform? Does it have to be a portable solution? Can you use anything else?

Member Avatar for TailsTheFox
0
4K
Member Avatar for artur7

Truthfully, that gives absolutely no advantage, bloats code, makes it hard to read, and is probably slower( although not noticeably ). And as your friend suggest, and your ego denied, its just bad coding. Drop this like a bad habit.

Member Avatar for mrnutty
0
98

The End.