537 Posted Topics

Member Avatar for Carrots

The string member [URL="http://www.cplusplus.com/reference/string/string/capacity/"]capacity()[/URL] is defined as: [quote] Return size of allocated storage Returns the size of the allocated storage space in the string object. Notice that the capacity is not necessarily equal to the number of characters that conform the content of the string (this can be obtained with …

Member Avatar for Narue
0
178
Member Avatar for lucky_43

Since you are using c-strings (character arrays) you do not get the luxury of using the <string> class overloaded == equality test. But what you do get is a bunch of [URL="http://www.cplusplus.com/reference/clibrary/cstring/"]<cstring>[/URL] library functions that will allow you to handle your character arrays with great ease: [CODE] #include<cstring> //instead of …

Member Avatar for Clinton Portis
0
133
Member Avatar for micromic

I do believe our good friend adrianxw can help you with your desired console graphics and/or mouse needs: [url]http://www.adrianxw.dk/index.html[/url]

Member Avatar for Clinton Portis
0
93
Member Avatar for aagajaba

I am really not sure what is going on here. You are attempting to use a main() function like I've never seen it before. Therefore, this method you are using is more than likely unconventional. To me, it seems like you are declaring an 'int' type variable called main (which …

Member Avatar for Clinton Portis
0
118
Member Avatar for mrsrinath

1. What specifically about the project is giving you problems? 2. Why did you take this course if you didn't want to make some sort of effort to learn the material..??!

Member Avatar for mrsrinath
-1
82
Member Avatar for Nika01

You pose quite the intruiging and insightful question: [URL="http://eternallyconfuzzled.com/index.html"]Binary Search Trees[/URL] [URL="http://eternallyconfuzzled.com/index.html"]Randomized Binary Search Trees[/URL] [URL="http://eternallyconfuzzled.com/index.html"]Balanced Binary Search Trees[/URL]

Member Avatar for Clinton Portis
0
157
Member Avatar for Mclovin1234

Here you create function specific variables that will be destroyed as soon as the function ends: [CODE] void calculateTotal(double heads, double tails) { double win = heads * 2; double lose = tails * 1; double total = heads - tails; [/CODE] Therefore, you have no method of keeping record …

Member Avatar for jonsca
0
94
Member Avatar for UKmason

[CODE] #include<cmath> height = (distance * tan(angle)) - (gravity * pow(distance, 2)) /2 * pow(speed * cos(angle), 2); [/CODE]

Member Avatar for Skeen
0
301
Member Avatar for isabellegagnier

[quote] can only use nested loops NO arrays or strings[/quote] I was kinda stumped at first until I came up with a linked-list of chars: [code] #include<iostream> #include<cctype> using namespace std; struct node { char letter; node *next; }; int main() { node *head_ptr = new node; node *list = …

Member Avatar for isabellegagnier
0
232
Member Avatar for nevets04
Member Avatar for JaBa

Just do the opposite of what you are doing and it will rotate your 'cube' in the other direction.

Member Avatar for Clinton Portis
0
107
Member Avatar for ukbassman88

[quote]Could someone please help me figure out what is wrong with my program?[/quote] Is there anything wrong with your program? I don't know. Does the program do something you don't want it to do? Do you have compilation errors? If so, what are they? You declare: float celsius and float …

Member Avatar for vmanes
-1
79
Member Avatar for snehil_khanor

[quote] jst m not able to think how to exrtract data from string.. [/quote] We can use our standard string parsing algorithm. In this case, we can use [URL="http://www.cplusplus.com/reference/string/string/find_first_of/"]find_first_of()[/URL] since we will have multiple delimeters (+, -, *, and / for example) [code] string expression = "5+104-32/5"; string terms[20]; int …

Member Avatar for snehil_khanor
0
5K
Member Avatar for thetechguy
Member Avatar for abraham james

Here is the pseudo-code for what you wish to accomplish: 1. create an array of integers that will be large enough to handle user input. This array will hold all of the 'n' rectangle data 2. using a loop, continuously prompt the user for coordinates until until such time user …

Member Avatar for Clinton Portis
0
102
Member Avatar for StaticX

This is a common mistake whilst performing tests using boolean logic; there is a distinct difference between the '=' assignment operator and the '==' equality test. (the '=' assignment operator should never be used to perform boolean tests)

Member Avatar for snehil_khanor
0
99
Member Avatar for godsgift2dagame

I am really unclear about what you are trying to accomplish... If you want to sort strings alphabetically, I can help you with some simple code. If you want to campare two strings, you could use the string class overloaded == equality test. If you are trying to compare two …

Member Avatar for Clinton Portis
0
224
Member Avatar for drake2212
Member Avatar for samsons17

you could probably do something like this: [code] int total = 0; for(int counter=0; counter < i; counter++) { total += product[counter].price; } cout << "Total goods sold is: " << total;[/code] Good looking well coded program btw. The only critique I have is that I would probably use a …

Member Avatar for samsons17
0
89
Member Avatar for freakgamerz

I just want to say that I love the title of this thread and I hope it stays at the top for awhile.

Member Avatar for Clinton Portis
0
188
Member Avatar for Shinedevil

you can easily perform a test on an entire range of values: [code] //If 'x' is greater than or equal to 1 AND 'x' is less than or equal to 380 if(x >= 1 && x <= 380) { //Do amazing things }[/code]

Member Avatar for Clinton Portis
0
141
Member Avatar for Instinctlol

If you were using an array of structs, I would simply just tell you to sort the array based on the desired struct attribute, and simply pick off the struct at the begging and at the end of the array. But since this is not the case, the best technique …

Member Avatar for Clinton Portis
0
506
Member Avatar for drake2212

Here is your insert node function: [code] void insertWord (ifstream& wordIn, wordRec *letters [], int& index, string& word, int& wrdIndex) { [COLOR="Red"]wordRec *head = NULL;[/COLOR] wordRec *newNode = NULL; [COLOR="Red"]if (head == NULL)[/COLOR] { newNode = new (nothrow) wordRec; newNode->newWord = word; newNode->previous = NULL; newNode->next = newNode; if (head …

Member Avatar for SriHanuman
0
504
Member Avatar for Burnout

[code] for (x = 0; x<15; x++) { storage[x] = number; cout << storage[x] << " " << endl; [b][COLOR="Red"]break;[/COLOR][/b] }[/code] the rest of your code looks pretty good i have to say.

Member Avatar for restrictment
0
122
Member Avatar for pokerDemon
Member Avatar for jbennet
0
110
Member Avatar for slim2hott

[code] #include<windows.h> #include<sstream> #include<string> using namespace std; /* Declare Windows procedure */ LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM); /* Make the class name into a global variable */ char szClassName[ ] = "calculator"; int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) { HWND hwnd; /* This …

Member Avatar for slim2hott
0
199
Member Avatar for mymyzzz

[quote]i am in need to change my char to int.[/quote] You are in luck.. char to int conversions are wicked easy.. (and so is any conversion among c++ standard primitive data types) Most people like to use the old c-style cast because it's quick and easy although technically it's not …

Member Avatar for pecet
0
159
Member Avatar for mymyzzz

[code] int counter=0; while(...) { ... ... ... counter++ } cout << "The while() loop executed " << counter << " times.";[/code]

Member Avatar for nambro
0
83
Member Avatar for rrvs331

I would read from the text file and store the contents of the .txt file into some sort of a container; probably a <string> class object. Once you have your string container(s) populated, loop through the string(s) and keep two counter variables that will increment any time a string == …

Member Avatar for Clinton Portis
0
76
Member Avatar for mymyzzz
Member Avatar for Clinton Portis
0
163
Member Avatar for jojojijijojo
Member Avatar for dylank

I believe ye' problemo might be here: [code] [COLOR="Green"]//Here you declare 'int counter = -10'[/COLOR] int counter = [COLOR="Red"]-10[/COLOR]; [COLOR="Green"]//Here you delcare an array[10] (creates elements 0 thru 9)[/COLOR] int xyMax = 10; int xData[xyMax]; int yData[xyMax]; [COLOR="Green"]//Here you attempt to access array elements less than array[0][/COLOR] for (counter; counter …

Member Avatar for Clinton Portis
0
118
Member Avatar for mymyzzz

This is what should be running through your head: 1. create an ifstream object 2. attempt to open a .txt file 3. perform error checking to see if file actually opened (may not exist) 4. If open, read in .txt file into <string> class containers 5. close the ifstream object …

Member Avatar for Clinton Portis
0
290
Member Avatar for mymyzzz

1. create an ifstream object 2. attempt to open a .txt file 3. perform error checking to see if file even exists 4. read in the entire file to an array of strings 5. close the ifstream object 6. using the <sstream> library create a ostringstream object 7. perform string-to-int …

Member Avatar for mrnutty
0
108
Member Avatar for bunnyboy

Let me offer this suggestion: Using the [URL="http://www.cplusplus.com/reference/algorithm/sort/"]sort()[/URL] function from [URL="http://www.cplusplus.com/reference/algorithm/"]<algorithm>[/URL] we find that there is an overloaded version of sort() that will allow us to supply our own custom-made 'test' function. Let's use this in order to specifically perform a test between two 'deques of structs'. We'll base our …

Member Avatar for Clinton Portis
0
137
Member Avatar for Star Frost

[quote]finding and storing the relevant line number the string was located at on the file in the token objects.[/quote] If I understand you correctly, you seem to be in need of keeping track of what line you are at whilst reading from a .txt file. So, I will suggest a …

Member Avatar for Star Frost
0
187
Member Avatar for lovely ari

What are you trying to do... your entire post doesn't make a lick of sense.

Member Avatar for lovely ari
0
114
Member Avatar for ab00120

Try this and see if it works for ye'... [code] std::string& write(); std::string& test::write() { std::string *name = "HELLO"; return name: }[/code]

Member Avatar for ab00120
0
96
Member Avatar for JoQsh

Good news.. the solution to your problem is wicked simple. May I recommend the [URL="http://www.cplusplus.com/reference/clibrary/cmath/ceil/"]ceil()[/URL] and [URL="http://www.cplusplus.com/reference/clibrary/cmath/floor/"]floor()[/URL] functions of the <cmath> library.

Member Avatar for JoQsh
0
152
Member Avatar for chubzyko

Here is suggested pseudo code for what ye' want to accomplish: 1. create an ifstream object (for opening & reading from file) 2. create an ofstream object (to write to the file) 3. open the source .txt file 4. perform error checking (see if file opened properly & if it …

Member Avatar for chubzyko
0
190
Member Avatar for Nixriq

In this block of code, you only make one call to 'infile' your data. You should consider infile'ing your data whilst inside of a loop to ensure you will read in data until you reach end of file: you have this: [code] else { //This code to read data only …

Member Avatar for Nixriq
0
159
Member Avatar for johndoe444

in line #8, you no longer need to typedef a second time... just go ahead and create your object: [code] addr a; [/code]

Member Avatar for Clinton Portis
0
68
Member Avatar for johndoe444

Here is a quick poor man's method: [code] int elements = sizeof(serviceinfo) / sizeof(serviceinfo[0]); [/code]

Member Avatar for Clinton Portis
0
83
Member Avatar for Nixriq

[quote] so my question is how do i center the first line ?[/quote] From what I understand, you are wanting to center a line of text on the dos console screen. Assuming that the standard screen will support 80 characters, we can derive the following formula: 40 - (string length …

Member Avatar for Clinton Portis
0
132
Member Avatar for jmoran19

[quote]The big thing I'm missing here is the correct way to parse a string and turn the values into... an array of variables? Or something more efficient I'm not even thinking of? [/quote] Very good observation, parsing your file-string into an array of substrings. Yes, there is also a way …

Member Avatar for jmoran19
0
113
Member Avatar for #www#

Try this: [code] #include<iostream> #include<sstream> #include<string> using namespace std; int main() { ostringstream oss; double number = 0.0; string string_number; cout << "Enter number: "; cin >> number; oss << number; string_number = oss.str(); cout << "\n\nThe number you entered is: " << string_number; return 0; }[/code] The above example …

Member Avatar for #www#
0
159
Member Avatar for AdRock

ispunct() may not be specifically what you are looking for to split up the string into tokens.. but I would suggest [URL="http://www.cplusplus.com/reference/clibrary/cstring/strtok/"][b]strtok()[/b][/URL] [code] char * strtok ( char * str, const char * delimiters );[/code] as you can see, strtok() accepts 2 arguments, the first being a c-string (char array) …

Member Avatar for Clinton Portis
0
370
Member Avatar for MasterDucky

Looks like you are attempting to sendmessage() to your listbox upon reciept of WM_PAINT messages.... and the only time I think your program will get a WM_PAINT is when you invalidate_rect() inside of your WM_COMMAND... So my question is: what is going to trigger the appropriate WM_COMMAND?

Member Avatar for MasterDucky
0
207
Member Avatar for infern0
Member Avatar for spookyfish

This may or may not be part of the problem, but it needs to be adressed: [code] if(player_card2 == 10|11|12|13)[/code] I did the same thing when I was first learning boolean logic and performing tests, and it took me a long time to understand why things are the way they …

Member Avatar for spookyfish
0
6K

The End.