1,426 Posted Topics
Re: Please post the code that you have right now. | |
Re: I think you can accomplish this a little easier than what you are doing. If you read the whole string in all you have to do is find the ' '(space). Once you know that position delete everything in the string to that location. now you are at the first … | |
| |
Re: As far as I can tell it should read as much as much as you type untill it hits a carriage return. I wrote a little test to show this [code=c++] #include <iostream> #include <string> using namespace std; int main() { string temp; cout << "Enter a big line of … | |
![]() | Re: To do this you need a sum variable that you will add to ever iteration. Then in your for loop all you have to do is add the part to the total. [code=c++] double sum = 0; for (int i = 0; i < n; i++) { sum += //calc … ![]() |
Re: To find out something like your first case you would need to do a couple things. First copy the string backwards into another string. Then start at the beginning of each string and check if the charectures match. I would pass both through either toupper() or tolower() so you can … | |
Re: Please post the code you have so far. We cant see your screen from here. | |
Re: With operator overloading one of the types must be a user defined type. reference: [url]http://www.parashift.com/c++-faq-lite/intrinsic-types.html#faq-26.10[/url] section: 26.10 | |
Re: IF you want to have 3 colums with 10 rows each then you are going to need 2 loops. One loop controls what row you are on and the other loop will control what colomn you are in. Look at this loop [code=c++] string foo[41] for (int i = 0; … | |
Re: Do you have to explain code someone else wrote for your exam? | |
Re: Please use English when posting on this formun. Another thing, you do realize this thread died over 2 years ago? | |
Re: What it is doing is testing if you broke the loop or ran to the end. If you ran to the end of the loop than [icode]if (j > (i / j))[/icode] will be true. If you broke the for loop because [icode]if (!(i % j))[/icode] returned true than [icode]if … | |
Re: Lines 37,40 and 43 are just using the variable volume not the function. To use the function volume you need to do [code=c++] cout << endl << "The volume of box 1 is "<< volume(var1, var2, var3); [/code] You might want to rethink your volume function though. It would look … | |
Re: You have a close curly brace after your while statement that shouldn't be there. Please re post your code with code tags to make it easier to read. Also you might want to look up proper indenting and code formatting styles. | |
Re: What error are you getting? If you are not getting an error what is happening? | |
Re: My motivation is that there is always something to learn. | |
Re: well in the ouptut function a and c are being passed to the function and in the input function radius is a global variable and doesnt need to be passed | |
Re: so you want the system call to say "Net User name"? If that's all then you can use a string and put the two parts together and then pass the whole thing to system. [code=c++] string command = "Net User "; string name; cout << "please enter the user name: … | |
Re: there is a simple approach to this problem. start at the begining of the array and sum all of the elements untill you reach your goal. then you need to store the begining and end posistion of that subset. then you will start at the 2nd element of the array … | |
Re: You should be able to get rid of it and still have compile. I believe stdafx.h is used to make non console based win32 programs. | |
Re: [URL="http://msdn.microsoft.com/en-us/library/17w5ykft.aspx"]This[/URL] should help you to get the arguments [EDIT] Wow Narue you are quick with the keyboard. Remind me never to get into a typeout with you. [/EDIT] | |
Re: Where is your temp variable coming from? | |
Re: the problem is you are using uninitialized variables to do your computations. in case 2 you are using yearsWorking without ever storing a number in there. | |
Re: part of the problem you are having with your multiplication is you are setting carry to 1 if the result is greater than 9 but that isn't right. 7 * 7 is 49 so your carry should be 4 in this case and not 1 as you have it. | |
Re: Why are you even declaring aonther DAI? If you want to youse the getCountry function all you have to do is [code=c++] for(int i=0; i < answer; i++) { A.push_back(DAI()); A[i].getCountry(); } [/code] | |
Re: The c++ standard gives no guarantee that a variable will be initialized to zero or null. Some compilers may add this functionality in but it is not guaranteed. You should always initialize your variables when you declare them. This is especially true for counter variables. | |
Re: line 10 should be [icode]count1 = count1 * 3[/icode] | |
Re: I would actually break this up into two functions. The function you have now would just be used to parse through the array and handle the return from the helper function. In the helper function I would do the calculations to find out if there was an increase or decrease … | |
Re: if you want to get totals for each item you will need a seperate array. then you can add the price into that array based on what they order. [code=c++] double totalItemPrice[8] = {0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00); // in you do loop cost += menu_list[order-1].menu_price; totalItemPrice[order-1] … | |
Re: What error are you getting? From the look of it you might need to define a operator= for your mat class. Also it is bad coding practice to define large functions inside the class. You should define them outside like [code=c++] class Foo { //... int Bar(int); //... } int … | |
Re: This looks more like c code and not c++. If you want to code this in c++ I would suggest using the string class in the stl. What error is your compiler giving you or does it crash while running? | |
Re: you could creat a couple of function like GetLetterInput and GetNumberInput and have them do the work so in your main function you wouldn't have to do all of the data validation. an example of how GetLetterInput might work is, [code=c++] ifstream & GetLetterInput(ifstream & stream, int & input) { … | |
Re: IMHO any class or function that you write that you use with different data types should be a template so you don't have to keep copy and pasting code and possibly creating an error in doing so. That said if you are writing a simple function for a program and … | |
Re: how complicated of an expression are you looking to solve? | |
Re: is B defined? I mean are you using this in a template function or class? | |
Re: in your .cpp file you will need to include the .h file that the defenition is in. than you define the functions like you would a normal function but you have to add the class name to the front of the function name. note that if you are using templates … | |
Re: Does this code work? There is no type for the variables first and last. | |
Re: a charecture is one byte long. to prove this try this code [code=c++] #include <iostream> int main() { char ch; std::cout << sizeof(char); std::cin.get(); return 0; } [/code] | |
Re: I would have the variable passed into the constructor of each class | |
Re: I would put an if statement in your second for loop for the empty rectangle and check to see if you are not on the top or the bottom of the rectangle. If you are not on the top or bottom then only place an Astrix on the ends otherwise … | |
Re: Check [URL="http://www.daniweb.com/software-development/cpp/threads/67837"]this[/URL] out. | |
Re: Please use code tags and standard code when posting. Also please don't resurrect dead threads. You must have seen the warning before you posted. | |
Re: I hate to nit pick but isn't the assignment supposed to use linked list? An array is not the same as a linked list. For info on linked list check [URL="http://www.codeproject.com/KB/cpp/linked_list.aspx"]this[/URL] out | |
Re: Another use for pointers is for passing to functions. When you pass a pointer to a function anything you do to it inside your function is retained in the calling function [code=c++] void foo(int a) { a += 5; } void bar(int * a) { *a += 5; } int … | |
Re: on line 72 you are checking to [icode]i <= 5[/icode] which will put you out of the bounds of the array. try changing it to [icode]i < 5[/icode]. | |
Re: I compiled your code and the only thing I had to change was to delete line 132. When working with iterators like you are you don't need to step one back from the the end. I could not get a duplicate of the data in the output though so I'm … | |
Re: instead of using a while loop ask the user for the number of students and then use that as the stop condition in a for loop [code=c++] // in main cout << "How many students do you want to enter: ": cin >> numberOfStudents; for (int i = 0; i … | |
Re: the problem is that if you try to enter a letter into a integer it will fail and cause cin to enter an error state and it will cause your program to loop forever. if you want to make it bulletproof you will have to get the input as a … | |
Re: I would suggest you read the file one line at a time using getline. After you read in the line pass it to a function that will go through the string and check for lowercase letters. Here is a way to get a counter for the lowercase letters [code=c++] int … | |
Re: Please show the code you have now and we can help you out. |
The End.