193 Posted Topics

Member Avatar for andrea_kay

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 …

Member Avatar for DevonMcC++
0
126
Member Avatar for chern4ever

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 …

Member Avatar for VernonDozier
0
233
Member Avatar for gregorynoob

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 ..

Member Avatar for dmanw100
0
149
Member Avatar for AorA

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 …

Member Avatar for AorA
0
186
Member Avatar for afromong

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 …

Member Avatar for stilllearning
0
89
Member Avatar for kenji

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"}; …

Member Avatar for stilllearning
0
76
Member Avatar for BINDERJ2

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]

Member Avatar for stilllearning
0
183
Member Avatar for kittycat07us

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 ?

Member Avatar for Alex Edwards
0
414
Member Avatar for blackryu21

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 …

Member Avatar for stilllearning
0
136
Member Avatar for amerninja2

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, …

Member Avatar for Salem
0
2K
Member Avatar for skvikas

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 …

Member Avatar for skvikas
0
149
Member Avatar for cutedipti

[URL="http://www.planetoid.org/technical/samples/va_args/va_args.c"]Here[/URL] is an example of a printf using va_args.

Member Avatar for Narue
0
128
Member Avatar for Dontais

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; } …

Member Avatar for VernonDozier
0
80
Member Avatar for NayNay33
Re: Help

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 …

Member Avatar for NayNay33
0
136
Member Avatar for chunalt787

You're using the wrong quotes [code] const char opTable[] = { '\0', '$', '(', ')', '^', '*', '/', '+', '-', '~' };[/code]

Member Avatar for stilllearning
0
150
Member Avatar for dtaylor01

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 …

Member Avatar for stilllearning
0
113
Member Avatar for san_sarangkar

Do you mean string to char* ? You could access the c_str() , which is of type const char*.

Member Avatar for stilllearning
0
169
Member Avatar for amerninja2

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 …

Member Avatar for Ancient Dragon
0
132
Member Avatar for tatainti55

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 + …

Member Avatar for tatainti55
0
105
Member Avatar for kavithabhaskar

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.

Member Avatar for skatamatic
0
6K
Member Avatar for Se7Olutionyg

Please add code tags .. and see your previous thread [URL="http://www.daniweb.com/forums/thread148791.html"]here[/URL]

Member Avatar for rati
0
122
Member Avatar for Alex Edwards

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) ?

Member Avatar for Alex Edwards
0
227
Member Avatar for mrboolf

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 …

Member Avatar for mrboolf
-1
151
Member Avatar for volscolts16

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 …

Member Avatar for stilllearning
0
346
Member Avatar for slow14

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 …

Member Avatar for ahamed101
0
157
Member Avatar for Evan M

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 …

Member Avatar for Evan M
0
102
Member Avatar for FAZ3

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++) { …

Member Avatar for stilllearning
0
104
Member Avatar for kurorokhristoff

[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 …

Member Avatar for Lerner
0
2K
Member Avatar for TheKebab

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 …

Member Avatar for TheKebab
0
94
Member Avatar for gangsta1903

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.

Member Avatar for gangsta1903
0
147
Member Avatar for JackDurden

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 …

Member Avatar for Agni
0
277
Member Avatar for grisha83

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 …

Member Avatar for grisha83
0
265
Member Avatar for jared_masc

Take a look at your previous post [URL="http://www.daniweb.com/forums/thread149899.html"]here[/URL] .

Member Avatar for stilllearning
0
122
Member Avatar for kevin7778
Member Avatar for Melab

If you are on Windows you can download the express edition of Visual C++ 2008 [URL="http://www.microsoft.com/Express/"]here[/URL].

Member Avatar for Narue
0
83
Member Avatar for Newguy89

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.

Member Avatar for Newguy89
1
109
Member Avatar for nizbit

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.

Member Avatar for VernonDozier
0
122
Member Avatar for Dontais

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 …

Member Avatar for Dontais
0
113
Member Avatar for grisha83

You can also use [URL="http://www.cplusplus.com/reference/algorithm/lexicographical_compare.html"]lexicographical_compare[/URL]

Member Avatar for grisha83
0
138
Member Avatar for PaladinHammer

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 …

Member Avatar for stilllearning
0
142
Member Avatar for unk45

[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 …

Member Avatar for mcriscolo
0
94
Member Avatar for onemanclapping

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.

Member Avatar for onemanclapping
0
115
Member Avatar for jared_masc

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.

Member Avatar for stilllearning
0
248
Member Avatar for transplantedNYr

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] …

Member Avatar for transplantedNYr
0
97
Member Avatar for DemonGal711

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]

Member Avatar for stilllearning
0
550
Member Avatar for En-Motion

You should be able to redirect using the > and the >> operators. [icode] myExe > output.txt [/icode]

Member Avatar for ahamed101
0
298
Member Avatar for Student_ABC

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 …

Member Avatar for Student_ABC
0
151
Member Avatar for JackDurden

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 …

Member Avatar for Sci@phy
0
88
Member Avatar for n8thatsme

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 …

Member Avatar for n8thatsme
0
203
Member Avatar for skatamatic

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 …

Member Avatar for ivailosp
0
319

The End.