- Strength to Increase Rep
- +5
- Strength to Decrease Rep
- -1
- Upvotes Received
- 12
- Posts with Upvotes
- 11
- Upvoting Members
- 11
- Downvotes Received
- 2
- Posts with Downvotes
- 2
- Downvoting Members
- 2
Re: I don't see any validity checks done for your dates. He can enter invalid dates like 33/33/2012. Once the dates are validated, the job is easy. [CODE] day1 = yyyy1 * 10000 + mm1 * 100 + dd1 day2 = yyyy2 * 10000 + mm2 * 100 + dd2[/CODE] Check … | |
I am planning to write an application in windows which will temporarily block the configured websites irrespective of what browser I am using. As I am completely a newbie in this I want to know where to start. Please provide me with any useful links which can help me. If … | |
Re: This [link](http://www.go4expert.com/forums/showthread.php?t=16676) explains better | |
I have a code which gives the maximum value I can get by filling the knapsack with the optimal set of weights. int arr[5] = {0, 0, 0, 0, 0}; int Weight[5] = {2, 5, 8, 7, 9}; int Value[5] = {4, 5, 7, 9, 8}; const int n = … | |
Re: if (0 > spendMinute) { spendMinute = 60 + spendMinute; spendHours-- ; } Add this piece of code at line 15. It will work | |
Re: > cin >> Point::m_Xcoord >> Point::m_Ycoord; I didn't take the effort to understand what you are trying to do but there is definitely an error at line 38. You cannot access structure member variables using :: operator unless they are static. You need to create an instance of structure to … | |
Re: Boost library is one option. But given that you are a beginner, and you want to go the hard way by using less complex C++ concepts, then think and note down how you will do this task if you were asked to do it manually. 1. take the given day, … | |
Re: It's already in string int main ( int argc, char *argv[] ) | |
Anybody of you got any idea what this "internal compiler error: Segmentation fault" means? I searched internet, but didn't get anything useful. Then I did my analysis. I found out something peculiar. The code that I am trying to compile is a file for unit testing one of our classes. … | |
Re: Line 19 - 23 : Why can't you use a similar loop condition as used in line 3 - 7 | |
Re: Dude, this has hundreds of errors when I compiled. Either you post a proper code or point out which line of code concerns you. | |
Re: Why can't you do something like this. [CODE] unsigned int mm; //holds the month unsigned int dd; //holds the day unsigned int yy; //holds the year unsigned int ordinal_day = 0; //holds your ordinal day number //define an array which holds the number of days in each month unsigned int … | |
Re: Common mistake that everybody makes. :) Line 21 : use "&" in scanf | |
Hi, I have overloaded assignment operator like below and it worked perfectly fine. [CODE]void Test::operator = (Test& obj) { this->a = obj.a; this->b = obj.b; } [/CODE] But when I googled more about this, I could see all of the examples used a different prototype like this [CODE]Test& Test::operator = … | |
Re: Dude, you are giving us a 500 line code and asking us to find the bug. Why can't you debug a bit on your own and post only that code portion which is the reason for your "lock up"? | |
Re: what is your large number? which data type are you using to hold large numbers? | |
Re: why is there no enclosing brackets for the lines under for loop? Is it intentionally missed out? From the logic under for-loop, I don't think so | |
Re: A tricky way, may not be the best way. Here it is: [CODE]#include <iostream> using namespace std; int main() { int a[2] = {1,5}; long addr1 = (long)(&a[0]); long addr2 = (long)(&a[1]); cout<<(addr2 - addr1)<<endl; return 0; } [/CODE] take absolute value of addr2-addr1 inorder to avoid a negative answer. | |
Re: Ok, if you want to retrieve the info at the last use "back" [CODE]a_student.assignments.back()[/CODE] If you want to retrieve from anywhere else using an index, use "at" [CODE]a_student.assignments.at(4)[/CODE] See this [URL="http://www.cplusplus.com/reference/stl/vector/"]link[/URL] for more info | |
Re: at line 29 you are setting seconds back to 0. So it's an infinite loop. Use a different variable in for loop condition. | |
Re: I didn't take the trouble in going through your entire code. But what sounds to me is that you have to use a static variable as ID. Initialize it to 1. increment it every time you add a patient. | |
Re: [QUOTE=phorce;1760048]Hello, basically I want to return an array from a function (So I don't output things in the class - just main) But I seem to get the error: "invalid types 'int[int]' for array subscript" Here is the code: [code] #include <iostream> using namespace std; int matrix() { int matrix[10] … | |
Re: [QUOTE=nezachem;1760178]Run away from that teacher as fast as you can. [CODE]y = 2*y++ + --x;[/CODE] [/QUOTE] Correct me if I'm wrong. But how is this an undefined behavior? I agree that the below line will give undefined behavior. [CODE]x = y++ * --y;[/CODE] Because we cannot predict which one (y++ … | |
Re: [QUOTE=nell16;1756980]1. Write a c++ program that generates the following series: 0 -1 4 -9 16 -25 36 -49 64 -81 100 and also this one - Nell[/QUOTE] Break it into two series 0 4 16 36 64 100 (square of even numbers starting from zero) -1 -9 -25 -49 -81 … | |
Re: try this :) [CODE]while(std::cin >> numberinput){ //std::cin >> numberinput; LinkedList.InsertFront(numberinput); }[/CODE] | |
Re: [QUOTE=shean1488;1758193]Yes it is, but not the way I want. The output is different[/QUOTE] It's pretty simple. You are not looping fully while printing. Make this change in line 40 - 43 (extra line added) and it will work. [CODE]for( i=0; i<c ; i++) { printf("%c", line[i]); } printf("%c", line[i]);[/CODE] | |
Re: use vector::assign See this [URL="http://www.cplusplus.com/reference/stl/vector/assign/"]link[/URL]. There is a similar example given. | |
Re: [QUOTE=thines01;1757547] The easiest way is just to set it to NULL.[/QUOTE] How is that possible? If you set it to NULL, the value will still be there and it is zero. [CODE] int a[5] = {1,2,3,4,5}; printf("%d", sizeof(a));//prints 20 as the size a[4] = NULL; printf("%d", sizeof(a));//prints 20 again [/CODE] … | |
Re: Are you asking what templates are? Or what is the job of template in your code? If you don't know what templates are, before trying to understand this code, you need to learn about templates. Take a good book or take some online material about templates and learn. I will … | |
Re: You are calling a non-const function by a const object. Hence the error. Make the functions as const and you'll get rid of this error. [CODE]int statistic::length() const { return amount; }[/CODE] There seems to be another solution to this. I haven't tried it and I seriously believe it is … |