193 Posted Topics
Re: You need to make and effort, work on this and post some code before we can help you out. If you aren't even familiar with variable declarations, I don't understand why your teacher is making you do file I/O, and something which is not a basic loop. [URL="http://www.cplusplus.com/doc/tutorial/"]Here[/URL] is a … | |
Re: Post some code so that we can see what you have attempted until now. If you have the same number of values on each line in your file then you can do something like this [code] ifstream myFile; // declare your data variables; // open your file // read the … | |
Re: How many squares are you supposed to build using your rectangle ? For instance if the length is twice the width or vice versa, you'd be able to split the rectangle into 4 squares using 2 lines. And then you could keep splitting it making smaller and smaller squares .. | |
Re: Not to keep harping on this, but you really need to be careful about the difference between an assignment (=) and a comparison (==). This means that you are assigning the value of the variable b to that of the variable MenuSelection. if(MenuSelection=b){ This means that you are comparing the … | |
Re: What is "a" defined as ? if you had something like this , and the user entered a number instead of "yes" or "no" , the string class would just store the value entered as a string, and you could check it. [code] string yorn; bool done = false; while … | |
Re: Did you replace [B][I]all the necessary lines[/I][/B] with the one initializer ? That makes it work for me. This might be a cleaner alternative if you want to use strtok to do your work to split the string up [code] int myCleanSpace(char s[]){ char* ptr; char delims[] = {" \n\t"}; … | |
Re: Well if you want to break it up for every hour you will need a loop [code] for (int i = 1; i <= time; i++){ cout << time << time * speed << endl; } [/code] | |
Re: Please put code tags around your code. Also, wouldn't it be easier to store the binary value you are computing in a string, inside your binary class ? And then just start at position starting point in the string and then scan for the next zero ? | |
Re: Using header[4] won't give a compile error, but it'll make the code crash at runtime. You should implement skatamatic's suggestions for changing your assignments (=) to comparisons (==) in your if statements, and also fix your array index accesses. Then you can check your output to see how much it … | |
Re: I don't think there is a type that will allow you support chinese characters natively. You will need some kind of unicode support for it. I don't know if there is an external library out there that will allow you to read these in. But in the absence of that, … | |
Re: I don't see anything wrong with the way you are allocating and de-allocating memory for the pointers. It works fine in a standalone program. Your error says that the free is being called twice on a specific pointer. You might want to put some print statements in your destructor to … | |
Re: [URL="http://www.planetoid.org/technical/samples/va_args/va_args.c"]Here[/URL] is an example of a printf using va_args. | |
Re: Well you need a loop if you want to keep asking the user for input until they enter -1. [code] { bool done = false; while (!done){ // ask for input and do my processing // when input is -1, set done to true and exit. done = true; } … | |
Re: A couple of things at first glance. When you use the istream operator to read the data from your paragraph, then you will be reading in one word at a time. So if you are looking for a phrase "an arbitrary end point" , then that will not work, the … | |
Re: You're using the wrong quotes [code] const char opTable[] = { '\0', '$', '(', ')', '^', '*', '/', '+', '-', '~' };[/code] | |
Re: First wrap your code in code tags . Now this line [icode] float 510 << wages << endl; [/icode] makes no sense whatsoever. You do realize that "<<" needs to be prepened by an object of the class ostream, not a variable of type float or a constant. If you … | |
Re: Do you mean string to char* ? You could access the c_str() , which is of type const char*. | |
Re: Would you elaborate a little more on what you are trying to do and what your problem is ? It looks like you want to delete a directory. I am a little confused by the use of "string *com2" .. why don't you just use "string com2" ? And that … | |
Re: Well you need to pass number1 and number2 to your Plus function. number and number2 are variables which are local to your main function, so Plus does not have access to them. Try something like this for example: [code] int Plus(int number, int number2) { int all = number + … | |
Re: The reason your code seg faults is because you have not initialized the variable "i" before using it in your while loop. If you don't initialize your variables correctly they will have random values. | |
Re: Please add code tags .. and see your previous thread [URL="http://www.daniweb.com/forums/thread148791.html"]here[/URL] | |
Re: I get the same compile errors, and it goes into an infinite recursion. I think the problem is trying to pass in the dimensions where the compiler expects type specifiers ? Perhaps an implementation of TwoDimensional<int> (int rows, int cols) ? | |
Re: Something like this might work. But I think you would be better off defining your nodes as classes instead of structures. It will give you encapsulation for your data. [code=cplusplus] template <class T> struct slist { public: T Data; slist<T> *next; }; template <class T> struct Dlist { public: T … | |
Re: Take a look a this function [code] struct tree_node * edit_node (struct tree_node *p, char l[], char f[]) { [/code] The prototype suggests that your edit_node should return a value of type struct tree_node* You have a if .. else if condition throughout the function, so if none of the … | |
Re: I am a little confused with all the file opening .. first you open Users.txt in your main() function .. then you open it again in your sign-up function. Is there a specific purpose to that ? And your fopen line [icode] file_ptr = fopen("Users.txt", "r+tb"); [/icode] Is your file … | |
Re: This is interesting. I have never really tried to insert elements into a vector in this fashion. I normally use the push_back() function to add values to the vector. I attempted to do what you are doing, and calling the resize() function calls the class constructor once and the destructor … | |
Re: First please read the rules and add code tags. No one will take the effort to read the code without those. Now here in your delete function [code] P=Front; //P points to Front Q=Front; //foor loop to deletes an element on I-1 place for(int i=1; i < (I-1); i++) { … | |
Re: [icode] for (int j = ?; ?; ?) cout << " "; // display blank space [/icode] this is a loop to compute spaces you need. Now look at the outer for loop and try to figure out how you can use that to set up the for statement in … | |
Re: I have been using VS2008 Express without any trouble. I am not sure what kind of a project you are creating. But for regular .exe's I create a WIN32 Console Application project, add the files to it and compile. For some compile issues, you may need to download the Microsoft … | |
Re: cin as you know will read your input variables separated by spaces. There no way to get cin to do what you want. You can use getline or you can overload the istream operator and write your own function to parse the input. | |
Re: You have to be a little more careful, but this is how you can do it. [code=cplusplus] int main() { int rows, cols; int **pointer; cout<<"Enter rows and columns for your 2-D array\n"; cin >> rows >> cols; // allocate a row of pointers. pointer = new int*[rows]; // for … | |
Re: You can use the while loop you have, intialize x to 1 before the loop and increment x each time in the loop. Another option is using a for loop [icode] for (int i = 1; i <= 5; i++){ // compute square of i // compute cube of i … | |
Re: Take a look at your previous post [URL="http://www.daniweb.com/forums/thread149899.html"]here[/URL] . | |
Re: why do I keep seeing the same thread ? | |
Re: If you are on Windows you can download the express edition of Visual C++ 2008 [URL="http://www.microsoft.com/Express/"]here[/URL]. | |
Re: I don't see you printing the spaces anywhere ? You can use "setw()" and "right" to set a width and then align your output to the right. | |
Re: Additionally, you can also paste some of your file contents here, and any code you have here, we can give you better ideas on how to proceed. | |
Re: You need to ask the question to input the grade inside your while loop, else it will keep looping on your first input infinitely !! [code=cplusplus] int main () { int grade; grade = 1; cout << setprecision(1) << fixed; cout << "Enter the Students Grade Between 1 and 100 … | |
Re: You can also use [URL="http://www.cplusplus.com/reference/algorithm/lexicographical_compare.html"]lexicographical_compare[/URL] | |
Re: Your names are fine as strings. Just the numbers can be ints for ease of use [icode] string name; int numbers[2]; .... ifile >> name >> numbers[0] >> numbers[1] ; .... [/icode] Although I don't understand this JAMES SMITH 828 24 shouldn't your two largest numbers be 824 and 786 … | |
Re: [URL="http://www.cplusplus.com/reference/clibrary/cstring/strstr.html"]Here[/URL] is an example of how you can use the strstr function to replace a substring with another. If you wanted to do it in your loop. You'd have to loop through until you matched up your first string, save the pointer to the beginning of the string and then … | |
Re: Well you have a few options. 1. You can make pessoas public 2. You can create a function called getPessoas() which will return a pointer to pessoas for that particular Liga object. 3. You can make Equipa a friend of Liga, that way it can access its data members. | |
Re: this is interesting [icode] char* toPLString(char * inputstring){ char *toPLString = inputstring; .... } [/icode] your function and your pointer have the same name :?: and the end of your string is '\0' not NULL. | |
Re: Are your numbers sorted in the descending order ? Because otherwise when you do [icode] if (first > next) return first; [/icode] it will always return the larger of the two numbers : test case 2, 1, 3, 4, 5, will return 2 as max. Also look at this [icode] … | |
Re: Your else is outside your while loop .. it might help to format your code more cleanly [code=cplusplus] while (location != NULL){ if (item == listPtr->item ){ return true; } } // while ends // now we have an else without an if // statement else{ return false; } [/code] | |
Re: You should be able to redirect using the > and the >> operators. [icode] myExe > output.txt [/icode] | |
Re: Well, you should be checking to see if your file pointers are valid or not before proceeding. And you need to read the data from your infile before you can write it to your outfile. You can have a counter that counts how many elements you are reading from your … | |
Re: Your startptr is of type T and you are trying to equate it to another pointer of type struct node* I think you need something like this. [code=cplusplus] template <typename T> struct node { T data; struct node<T> *next; }; template<class T> class snake { public: void example(); private: struct … | |
Re: Well if you have a person class, then it can have your get or accessor functions. for example: [icode] class People{ public: getFirstName(); ....... private: string firstname; ... } [/icode] And you should be able to have a vector of such objects to store all your values. Then you can … | |
Re: These lines here [icode] _cptPoints = new CPt [++_iSize]; _cptPoints = Tmp; [/icode] You allocate space for _cptPoints, and then you assign it to Tmp, which means you've now lost the memory pointer assigned by new CPt [++_iSize]; .. therefore not sure how you can delete it. That may be … |
The End.