1,608 Posted Topics

Member Avatar for ASHAR VIRK

Work long. Work hard. Work smart. Pretty much like any other any other skill. Oh, and it never hurts to have a friend, or in this case, a place, like DaniWeb, where you go to ask questions, get help, etc. You know, some one/place that respects you as long as …

Member Avatar for Excizted
0
78
Member Avatar for KaZu88

Why are you declaring arr like this: Participator **arr; instead of like this: Participator *arr; Your expand() method is wrong. Using vectors instead of arrays so you don't have to manage your own memory is probably the easiest way to correct this, however, the general way would be declare temp …

Member Avatar for Lerner
0
167
Member Avatar for hussamo

Compare your post to the following statement: My car only makes noise when it runs. Please help me fix it. It's a very broad statement/request, isn't it? Please try to narrow things down. Start commenting out functions and funciton calls one by one---starting with the least important, and recompile/run the …

Member Avatar for Ancient Dragon
-1
115
Member Avatar for new programer

If I understand the process correctly you want to:[code] //break each row in string_in in two based on the letters in the word GREEN KFZLQMDWJUSH GCEIXRAOPNVTYB IMWZPFJBKLTNOEQDHUXGVYAS RC FAMI ETZORWPSQUNGLDYBKXHCVJ XNAKVPICQHDFW EGBRTMLZOUSYJ ZSYFDOWIJCAKPBTXLRU NGQMVHE //Store the fragments in second and first first: GCEIXRAOPNVTYB RC ETZORWPSQUNGLDYBKXHCVJ EGBRTMLZOUSYJ NGQMVHE second: KFZLQMDWJUSH IMWZPFJBKLTNOEQDHUXGVYAS …

Member Avatar for new programer
0
103
Member Avatar for Sumer7720

a nested loop and using a protocol similar to do this should do the trick: Each cell of matrix X can be accessed by using the syntax similar to this. X[row][col]; Then matrix addition means the each cell in the result is the sum of the cells in the operands …

Member Avatar for Sumer7720
-3
37
Member Avatar for marirs07

Are you trying to print to the screen or to a file? Post the code for outtext.

Member Avatar for Lerner
0
318
Member Avatar for chuong3a

First, decide if you are doing this in C or C++. Your headers and output statement indicate C, but your memory allocation using the keyword new is C++. If this is supposed to be in C, then you would be best advised to post it on the C board. The …

Member Avatar for Lerner
0
94
Member Avatar for Waylon

Map is declared as an array. When arrays are passed as parameter to a function they are passed by reference by definition of the language. Being passed by reference means that any changes to the contents of the array within the function will remain in the array once the function …

Member Avatar for Lerner
0
106
Member Avatar for rafaqat hassan

For what type is it legal to use more than one char at a time in the type? That's the type that should be used to declare stack and the variables called a and b. Then you will need some other mechanism to convert that type to numerical values besides …

Member Avatar for Lerner
0
77
Member Avatar for samsons17

You could try outputting 50 lines of blank space to the screen every time you want to clear the screen.[code] void clearscreen() { for(int i = 0; i < 50; ++i) cout << '\n'; }[/code] However that will probably leave the cursor in the left lower corner. To reposition the …

Member Avatar for DarkC0de
0
142
Member Avatar for muzamal

I'd create a class to represent a matrix. At a minimum I'd use 3 data, two ints-one each for number of rows and number of columns to use and a pointer to pointer to type. I'd get the number of rows and columns for a given matrix and then use …

Member Avatar for Lerner
-1
99
Member Avatar for Spiderpig085

I'd change the single | to a double ||. The ostream method write() takes two parameters and I find it difficult to see how the return type of DrawBoard(), whatever that is, can provide both parameters. If DrawBoard() uses cout you could write a second version using an ofstream (or …

Member Avatar for Ancient Dragon
0
105
Member Avatar for tinkeydo

You have to redeclare a size for length other than zero every time through the for loop as it goes to zero in the while loop.

Member Avatar for alvinwong
0
95
Member Avatar for Hathake

First, welcome to the board. Second, thanks for figuring out how to post code using code tags. Much appreciated. Third, except for line #1 your code is written in classic C style, not C++ so posting to the C board may get you more responses. As some of my concerns …

Member Avatar for Lerner
0
83
Member Avatar for darkunknown

As long as it is declared before it is called and is defined somewhere the compiler/linker can find it, go ahead.

Member Avatar for Ancient Dragon
0
103
Member Avatar for lkegley

NumGames needs to be in scope in order for this to work, too. Also, this: Games[i].GetHomeScore suggests an accessor function for a member variable of the object Games[i] called Home Score based on the prefix Get before HomeScore. If that is indeed the case, then there needs to be a …

Member Avatar for Lerner
0
103
Member Avatar for C++ Beginner
Member Avatar for C++ Beginner
1
231
Member Avatar for Lilal

[code] int counter[10] = 0; //initialize all counters to zero int numUnique = 0; //to keep track of unique strings found so far int arrayCell; //declare outside loops to keep in scope throughout loops while(inTxtFile >> lineRead) { for(arraycell = 0; arraycell < numUnique; arraycell++) { if (uniqueString[arraycell] == lineRead) …

Member Avatar for Lerner
0
346
Member Avatar for eduard77

What type of array to you think fMatr is? Or putting it another way, is fMatr declared as a single dimensional array or a two dimensional array?

Member Avatar for Lerner
0
84
Member Avatar for kellnerq

Delete lines 16, 17 and 18. Delete everything to to the right = signs in the equations in lines 20, 21, 22 and put the = sign in the string identifying the operation that is being done. cout << "The diameter is = " << 2 * radius << endl;

Member Avatar for kellnerq
0
85
Member Avatar for Snapster5

Line 11 is just plain weird. It has two types followed by a function name and parameter list. I thing what you did was declare main() as type void on line 11 initially with a function prototype for fomat_string() on line 9 or something. Then you cut main(){ and moved …

Member Avatar for Lerner
0
147
Member Avatar for asweetroxxi

All you want on line 32 is the command from the user. To look a little further, how are you going to know how many operands remain on the stack and whether it's valid to call another command. I'd suggest you check to make sure there is more than 1 …

Member Avatar for Lerner
0
133
Member Avatar for progag

Start with task #1. When you can do that then try doing task #2. When you can do that then try #3. Don't think of the whole program all at once. Once you have both matrixes, then the code to set up the actual multiplication, task #6 can be done. …

Member Avatar for Dave Sinkula
0
96
Member Avatar for spookyfish

Since you don't know how many salesmen or how many sales there will be you are probably better off using a list or a vector (if you know about these containers) because they enlarge as needed, rather than declare an array of salesmen that is "likely big enough"; though if …

Member Avatar for Ancient Dragon
0
124
Member Avatar for BobRoss

As jonsca said, any newline char in the file opened by the stream called plainText will be eliminated from the stream by getline() as it is the default delimiting char for getline() and getline() doesn't include the terminating char in the string that it uses. That means that plainLine will …

Member Avatar for BobRoss
0
122
Member Avatar for ukbassman88

Don't think too much about parts 2 and 3 when working on part 1. The instructor has it set up so if you can do earlier parts as instucted it they will flow nicely into latter parts. Once you have more experience you can think of the whole program in …

Member Avatar for Lerner
0
132
Member Avatar for ukbassman88

If you know about boolean types you could consider returning a boolean variable instead of a string variable. At least that's the type I think of when I want/need to return true/false.

Member Avatar for ukbassman88
0
95
Member Avatar for Snapster5

Now it looks like a cut and paste disaster. Scrap the last post and go back to your first post. Then using post #1 try fixing one error at a time as suggested in post #s 2 and 3. (Better yet, in the future only write one or two lines, …

Member Avatar for Snapster5
0
146
Member Avatar for UberJoker

Isolate (using whatever method you like) the last two char of each string as a substring and then convert the substring to an int (using whichever method you prefer). There are at least two ways to do each the isolation and the conversion.

Member Avatar for UberJoker
0
208
Member Avatar for 07tr0wa07

You have two variables with the same name, fileName, which may well be problematic, but I see only two calls to selection sort, neither of which have the 4th parameter as an array and the types passed seem to match the declaration and definition argument lists, which each match, so …

Member Avatar for Lerner
0
276
Member Avatar for richman0829

What is sizeof(e) anyway given that name can have any size up to 79? If you wanted to use write() I would recommend using two separate calls, one using strlen(eArray[counter].name) as the second parameter and the other using sizeof(eArray[counter].salary) as the second parameter. So, all in all, I think the …

Member Avatar for Lerner
0
108
Member Avatar for Snippset

You need to be as precise as possible in explaining what you are trying to do. For example, DOG and GOD have the same letters in each word, but are not the same word and DOG and SUN don't have any of the same letters in common. On the other …

Member Avatar for Snippset
0
170
Member Avatar for gedas

Googling leads me to believe that an adjacency matrix of a graph is an n by n matrix where n is the number of vertexes represented in the graph. The rows represent which vertex you are starting from. The columns represent which matrix you are going to. If you can …

Member Avatar for Lerner
0
81
Member Avatar for guccitan88

intNumberOfElementsToStore should be an int, not an array of ints. It should be generated in main(), line 17 looks like a good spot to do it. Declare the array with a name like PartiallyLoadedArray, which is probably better than the generic name of a that jonsca used, though I know …

Member Avatar for guccitan88
0
134
Member Avatar for Rockdrummer357

If you are trying to write code for a tree then I assume you are familiar with writing code for a list. You can think of a list as a tree that has only 1 child per node and they all rights or lefts or nexts or whatever else you …

Member Avatar for Rockdrummer357
0
108
Member Avatar for PDB1982

Frist, main() should return type int, not type void. Even if your compiler allows you do use reurn type void, don't do it. The problem you allude to however, probably has to do with line 118. If you use the return value of eof() to control performance of the loop …

Member Avatar for Lerner
0
121
Member Avatar for pac-man

4 is a default value. If you had written line 12 like this: Car("Ford"); it would still be valid as the argument list would default the second argument to 4 rather than the 3 you actually used. const means that whatever is done within the constructor it cannot change the …

Member Avatar for pac-man
0
108
Member Avatar for confusedndazed

Functions must have a declaration and a definition. If the fucntion is defined before main() then the declaration and the definition are the same. If the function is declared before main() it is frequently called a prototype. To use a function within the program it must then be called. The …

Member Avatar for Lerner
0
93
Member Avatar for XodoX1

First welcome the board and thanks for using code tags, but I think you might have used the wrong ones and it mangled your indentation----at least I hope that explains the lack of indentation. Second, the way I read the instructions is to do something like this;[code] class Division { …

Member Avatar for Lerner
0
154
Member Avatar for fradiavolo

First, welcome to the board. Then not necessarily in order of importance: 1) Your syntax is more C than C++. You might get better response posting on the C board section of this site rather than the C++ board. 2) Thanks for using code tags when posting but 3) Hopefuly …

Member Avatar for Lerner
0
261
Member Avatar for StaticX

int * ptr; This is a pointer to an int. It isn't an array. It can be used like an array when you assign memory to it using the new[] operator. int num = 6; int * ptr = NULL; //null ptr ptr = &num; //ptr points to num. you …

Member Avatar for StaticX
0
339
Member Avatar for amosda4183

Ok, here's a comparable question. My car wouldn't start this morning. Can you fix it? Pretty broad scenarion, eh? Please be more specific with your question. If the code doesn't compile give the error messages. If the code gives wrong output, give observed output in addition to desired output. If …

Member Avatar for Lerner
0
330
Member Avatar for grib

I still don't understand the question. Please be more specific. I do see that you don't null terminate can->name in putCandy() so technically can->name is a simple char array not a string. Try fixing that and see what happens. If it doesn't fix things then post with a specific question.

Member Avatar for grib
0
149
Member Avatar for trcartmill

I'm not sure what your last post is trying to say. The char by char way to limit the name part of the line to 29 char after the full name has been received could be something like this:[code] string fullString = //whatever; string clippedString; int len = fullString.length() if(len …

Member Avatar for Lerner
0
135
Member Avatar for fragtech

What type of string are you trying to enter? If the first string has whitespace in it (eg, Jim Jones instead of Sally) then the behavior you describe could occur.

Member Avatar for zobadof
1
104
Member Avatar for amishraa

Build on what you know. For example here's a progression you might be able to use. Write code to read the whole file one line at a time and display the line to the screen. Modify the above code to read in one word at a time, whether the word …

Member Avatar for amishraa
0
155
Member Avatar for laelzio.mosca

you have some "rounding problems" because C++ uses integer math, not regular math, when dividing an int into an int and then assigning that value to an int (see calculatin of cooktime which is subsequently used for calculation of oventime). Whether that's enough to cause your error I don't know …

Member Avatar for valtikz
0
88
Member Avatar for jigglymig1

The domain name can't be moc gro or ude all at the same time. So at least two of the three conditions must be true and given the OR operator that means the whole condition is true. How about using the == operator instead of the != operator and in …

Member Avatar for jigglymig1
0
95
Member Avatar for kako13

Depends what you want to do when the edit has been completed. If you want to write corrected information back to file then you need to write the whole file into your program, edit the record, then rewrite the whole file back to file. IF the edit takes up exactly …

Member Avatar for Lerner
0
230
Member Avatar for rena0514

Since you have access to the internet I would suggest you do a search on Google or you favorite search engine if you don't have adequate information in your course reference material or class notes. cppreference.com has a listing of all the STL set class methods with their prototypes and …

Member Avatar for rena0514
0
113

The End.