- 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
75 Posted Topics
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 … | |
Re: What problem are you facing? Post the error that you get. Also please edit your first post by aligning the code properly and wrap [code] tag so that it is easily understandable for us to analyze. | |
Re: [QUOTE=Dumb Fish;1749077]hi, i need to ask how to generate the negative answer? i have one formula. But always give me positive answer.. For exmaple: [B]AllocatDiff2 = 100 * -0.05;[/B] hope somebody can help me ...ASAP!! Thanks ...[/QUOTE] is AllocatDiff2 and unsigned int? | |
Re: How about this??? :cool: [CODE] unsigned int grade_index; unsigned int score = 35; //this is your score. use scanf to get it. grade_index = score/55 + score/65 + score/75 + score/85; char grade = 69; grade = grade - grade_index; printf("%c", grade); [/CODE] | |
I am trying to implement my own version of BigInteger which can hold an arbitrary big integer. I have posted my BigInteger.h file here and I need your suggestions if there is any better design for this. 1. std::string private member will hold the BigInteger in the form of string. … | |
Re: You are passing the pointer by value. And you are swapping the copy of the actual pointers in swap() function. When it comes out from the function, the pointers' copies go out of scope and hence no swap happens. One solution is to pass the pointer by reference. Other solution … | |
Re: What I understand from your requirement is that your Swarm object will contain Particle(s). Each Particle has a unique dimension_id. Why can't you use map in Swarm class. A map where the key is dimension_id and value is a Particle object. Please correct me if my understanding of your requirement … | |
Re: have you included iostream? | |
Re: I think a closing bracket is missing | |
Re: This should help [url]http://www.daniweb.com/software-development/c/threads/398451[/url] | |
Re: That didn't look like a circular linked list. Anyway, I made a few corrections and it worked fine. [CODE]void add() { int n; cout << "What is n? "; cin >> n; if (n > 0) { Head = new(node); Head -> Item = n; Last = Head; for (int … | |
Re: 1. Line 49 : It should be [CODE]temp1->ptr=temp;[/CODE] 2. Line 67 and 69 : You repeat the same statement. Delete both the lines and bring one of them after the if-condition. [CODE]if(temp1->ptr==NULL) {return 0;} temp1=temp1->ptr;[/CODE] Now it's up to you to think and find what error you made and how … | |
Re: [CODE]bool dayType::equalDay(const dayType& otherday) const { return (this->day == otherday.day); } [/CODE] "this" is the object with which you are calling equalDay(). You are comparing this's day and otherdays's day and returning the result. | |
Re: I didn't try to understand what you are doing in your code. But, I see one mistake. Variables like digit10 which is of int type cannot hold such a big value. If int is of 4 bytes, it can go only till 2147483647 but digit10 is assigned with 68719476736. | |
Re: [QUOTE=firebird102085;1740892] Error 1 error C2106: '=' : left operand must be l-value (error on line in bold) [/QUOTE] Did you mean to put the value you get after summing [B]sum[/B] and [B]count[/B] into [B]ex[/B]. If so, you should do like this. [CODE]ex = sum + count;[/CODE] [QUOTE=firebird102085;1740892] Warning 2 warning … | |
Re: the reason why no body is helping is that your code is not intended at all, which makes it difficult for us to read. Please format it with proper intendation and the re-post. Also remove all the blank lines in between. | |
Re: [QUOTE=stereomatching;1739284] I write a small program to measure the time [/QUOTE] Why don't you put the solution in a loop. Loop it some 100000... times, so that your program will give you some number. Do it separately for both solutions. | |
Re: I find lot of bugs in your code. 1. In the main function you are calling [B]createAndCount()[/B] without any arguments, but where as from the signature of the function, it is seen that it accepts an integer. 2. In [B]count()[/B] you are using a variable 'n' in the for loop. … | |
Re: You can simply enter your input separated by spaces. It need not be \n character always. For cin>>i>>j; you can actually enter two numbers separated by space. Or, you want a space to be inserted when you press enter, and wait for the next input? | |
Re: check this link, this should help you [url]http://linux.die.net/man/3/strtol[/url] For C++ programmers, there is another solution [url]http://www.cplusplus.com/articles/numb_to_text/[/url] | |
Re: [QUOTE=freedomflyer;1738022] once it gets back to process_and_display_information, the data is gone.[/QUOTE] Yes, it will be gone, because the scope of [B]myStrings[/B] is only within [B]tokenize_urls[/B](). [B]myStrings[/B] is created in the stack and once the control goes out of [B]tokenize_urls[/B](), the memory will be freed. That is why you lose your … |
The End.