- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 13
- Posts with Upvotes
- 10
- Upvoting Members
- 10
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
35 Posted Topics
Re: You get those results because you base your sorting on the "name" of the month. Well... The months of the year are obviously not in alphabetical order. So thats gonna get quite messy. To get the desired result, you have to sort the months by number, instead of name. | |
Re: Hi anuragcoder :-) The error is caused by the fact that malloc returns a void*. You can not make an implicit cast of a void* to another type, you have to make it explicit: [CODE] string = (char*)malloc(strlen(str)); [/CODE] | |
Re: Hi Hyiero The problem is that cin.get(board) does not remove the 'newline' from the input stream. Look at the sticky thread called "How do I flush the input stream?" That should solve your problem | |
Re: The problem is somewhere in your quicksort algorithm. Testing your code with 100 elements, seems to complete. BUT the output is not perfectly sorted. [CODE] Enter the number of elements 100 0 99 0 20 0 1 3 20 3 7 3 5 3 4 9 20 9 16 11 … | |
Re: [code=c] void list::count_delete(int x) { node *Now=first; node *Pre=NULL; if(first->next!=first) { while(--x>0) { Pre=Now; Now=Now->next; } //What is the value of Pre, at this point, if the initial value of x is 1 ? Pre->next=Now->next; delete Now; } //What is the value of Pre, at this point, if first->next == … | |
Re: The reason you get error C2440 is in line 19: [code] totalScore = totalScore + tempPtr; [/code] You are attempting to add an int (totalScore) and a memberInfo struct pointer (tempPtr). What you want to do is add the score-member of the memberInfo struct, like this: [code] totalScore = totalScore … | |
Re: 1) In lines 27 and 28 change < to <= 2) Remember to output an endl at the end of the outer for-loop [code] for(int i=1; i<=length_stars; i++) { for (int j=1; j<=length_stars-i; j++) { cout << " "; } for (int h=1; h<= i; h++) { cout << "*"; … | |
Re: Based on your own idea to use the []-operator (index-operator): Student students[2]; for(int i = 0; i < 2; i++) { cout << "Enter First Name: " << endl; getline(cin,Firstname); students[i].setFname(Firstname); cout << "Enter Last Name: " << endl; getline(cin,Lastname); students[i].setLname(Lastname); } | |
Re: I have not made any further tests but... c11, c22 and c33 are pointers to cashier-structs (line 9). In line 30-32 you use the indirection-operator (->) to access the cashier instances pointed to, but you never created the cashier instances. c11, c22 and c33 are pointing to some random memory. | |
Re: Hi Rallici :-) You should wrap you header-files in 'include guards'... That will probably remove the problem. [CODE] #ifndef HEADER_INCLUDED #define HEADER_INCLUDED //Header content #endif [/CODE] Btw: The 'include guard' in Global.h has a typo. You miss-spell GLOBAL_DEFINE in the first line. | |
Re: Hi new2programming :-) Replace \ with \\ in the string. \ is used to put special characters in a string ('\n' is a newline). To put a '' in a string you type '\'. The beeping sound might be caused by the fact that the file can't be found. | |
Re: Hi Shaida :-) When declaring the functions 'hi' and 'name' at the top, you have to end the statement with a ';'. Like this: [CODE] #include<iostream.h> void hi(void); void name(void); int main() { ... [/CODE] | |
Re: Hi aaronmk2 :-) I think I have found the reason for your runtime error. Take a look at your remove-function, where you delete the last node in the Que. You extract the string and delete the node but you NEVER set the 'front' and 'rear' to NULL. The next time … | |
Re: Hi Alex_ :-) In "Select all smaller than...": *) Why don't you just use 'cin >> it;' to read the number, like you do everywhere else. *) When you find a number smaller than 'it', you push it to the back of the vector v2. But v2 is just a … | |
Re: Hi mugilan :-) The problem is in your if-statements, handling the menu: [CODE] if(transaction_type = 'X') return; if(transaction_type = 'O' || 'D' || 'W' || 'B') break; else cout<<"\n Invalid type. Please try again"; [/CODE] 1) To compare transaction_type to 'X' you have to use the == (equality) operator, NOT … | |
Re: Hi JStarr :-) Found three errors in your code: 1) In the top you declare the function initializeArray, but in the rest of the code you call it initializeArrays (Note the 's'). 2) In startlotto your if-statement is supposed to be a for-statement 3) The ';' at the end of … | |
Re: Hi jimJohnson :-) Sorry to say, but you have got it wrong. f is a recursive function, meaning that the function calls itself. Let's have a look at what happens in this call: [CODE] f('B'); [/CODE] These are the steps in you algorithm. [CODE] f('B') if-statement evaluates to true. f('B' … | |
Re: Hi etisermars :-) The line [CODE] delete [] p; [/CODE] will only delete the array of pointers, not the objects the pointers point to. You will have to handle the destruction of the ClsA-objects yourself. If you don't you will have a memory leak. Have a look at my simplified … | |
Re: When shifting the bits you loose the bits that gets "pushed out". You don't rotate the bits. Lets look at your examples (in binary): [CODE] a: 0000111110100000 a << 3: 0111110100000000 a << 19: 0000000000000000 [/CODE] | |
Re: Hi ferenczi :-) Take a look a close look at your insertEdge-function. In particular the content of the else-statement. Consider what happens in the while-loop. While the incList-pointer is not NULL, you make it point to the first elements next-pointer. When the while-loop completes the incList-pointer will always be NULL. … | |
Re: Hi broli100 :-) Give this a try: [CODE] RECT rct; rct.left = 20; rct.top = 20; rct.right = rct.left + 30; rct.bottom = rct.top + 100; InvalidateRect(NULL, &rct, 0); [/CODE] LPRECT is short for "Long Pointer to RECT". | |
Re: Hi aleX_X :-) I have not solved the problem for you, but I think I have figured out what is wrong. First of all I've found a couple of bugs in your code: 1) In your main-function, take a look at this code: [CODE] botx=mech.bot.getx(); boty=mech.bot.getx(); [/CODE] Erhm... Bot-Y = … | |
Re: The reason you get the 'messy' output is that you add 32 to all char's with a value less than, or equal to, 90. That works just fine for the alphabet but when you reach the 'string terminator' ('/0') things go bad. /0 simply has the value 0. You end … | |
Re: Hi dflatt :-) In your code you are comparing the value of variable c to the values of variables a and x. Those variables probably don't even exist. To compare the value of c to the characters a and x you write it like this: [CODE] if(c <= 'a' && … | |
![]() | Re: Hi Sinaru :-) Since I don't know how familiar you are with stuff like this I have too ask: You represent a negative binary number as a positive binary number prefixed with a '-'. Is that your own intentional design or because you do not know the real way to … |
Re: Replace [CODE] file.close; [/CODE] with [CODE] file.close(); [/CODE] | |
Re: To send TAB 13 times: [CODE] SendKeys.Send("{TAB 13}"); [/CODE] | |
Re: Are you required to use a two-dimensional array as datastructure? If not I would suggest that you use a 'struct' to create some kind of StudentRecord-datastructure. I have tried to make a rewrite of you code, using a 'struct': [CODE] #include <cstdlib> #include <iostream> #include <cmath> struct StudentRecord { int … | |
Re: Hi ollie60 :-) There is no need to allocate any dynamic memory like that. You don't need to allocate a new vector. All you have to do is calculate the sum of the values from nodeVec and push it to the back of zMap: [CODE] vector <double> mapNodalData(vector <Vec*> nodeVec, … | |
Re: Well hello again smcp :-) You actually got the part about operator overloading right. The problem is the keyword 'const'. One important aspect of 'const' is that: a) A non-const object can call both const and non-const functions. b) A const object can call const functions, but NOT non-const functions. … | |
Re: Hi tarheelfan_08 :-) You have implemented you stack as a linked list, but when you push a new element you forget to add the current 'top' to the new element. That is why you only have the last pushed element on the stack. Your current push: [CODE] void Inventory::push(string description, … | |
Re: Hi phummon You should consider using the std::map to map from a string to an int. A quick rewrite of your class using map: [CODE] #include <iostream> #include <map> #include <string> class FruitCart { public: // Constructors FruitCart(); ~FruitCart(); // Accessors void SetFruit(int a, std::string FruitType); int GetFruit(std::string FruitType); void … | |
Re: Hi theblastedfool :-) Your problem is in the checkpass-function. Let's take a look at the check for a lower case letter: [CODE] for ( int i = 0; i <= length; i++) { if ( pword[ i] >= 97 && pword[ i] <= 122 ) { lower = true; break; … | |
Re: Hi Smcp :) Segmentation fault means that you are trying to read or write memory you do not have access to and that is exactly what is happening in you main-function. You have created two arrays fName and lName containing five elements each. No problem there. In your for-loop you … | |
Re: I have not taken a closer look at your code, so i'm not sure what you are trying to do but... There is a BIG problem right here: [code=c] while (At_Bat >= Hit); [/code] IF the condition evaluates to true, you are entering an infinite loop. |
The End.