138 Posted Topics

Member Avatar for JDean89

The function identifier says it all. [CODE]int total(int value1, int value2)[/CODE] The 'int' at the beginning tells that your function returns an int value when called. Therefore, it is logical that an 'int' value is return when you call the function at line 8 of your main method. [CODE]total(num1,num2);[/CODE] You …

Member Avatar for chiwawa10
0
116
Member Avatar for nhidman

Hi nhidman, what are you trying to achieve by splitting and then merging the audio file? One simple example has been given by prvnkmr449. That is to treat the audio file just like any other binary file. Split them into the number of chunks that you like. Then reading each …

Member Avatar for chiwawa10
0
180
Member Avatar for rtdunlap

Beware of the code [CODE]chsum = ch2+ch3+ch4;[/CODE] There may be buffer overflow due to the limitation of data type [B]char[/B] which can have maximum value of 255 only.

Member Avatar for LordNemrod
0
123
Member Avatar for bookmark

Logically thinking, it is a math problem. Fortunately, C/C++ has a built-in library catering for common mathematical needs. You may want to look into these two functions: floor() and ceil() Both from the math.h library.

Member Avatar for packetpirate
-1
112
Member Avatar for RFBourquin

You may want to have a look at WMI (windows management instrumentation). It provides an extensive API for accessing your systems information.

Member Avatar for 7sedam7
-1
2K
Member Avatar for Excizted

Its good to see that you have the functions well separated. May I suggest you perform some unit test to ensure that your functions are returning the expected results? If each function are doing fine, then, most likely your program has some logic error.

Member Avatar for Excizted
0
196
Member Avatar for tinanewtonart

Based on my understanding of your question, you are requesting help to check on your main() function's logic. Hence, I will comment only on the main() function part. 1. Why do you need to declare a ChildGame object in the do..while loop? All you need is only one game. 2. …

Member Avatar for tinanewtonart
0
1K
Member Avatar for anuragcoder

You have to add an else statement after line 9 [CODE] if (text.empty()) { ++nl; } else { // to save, assign text to a variable here } [/CODE] It is because the text will be overwritten in each iteration at line 4. Logically, when user presses enter twice, the …

Member Avatar for anuragcoder
0
2K
Member Avatar for jimJohnson

Are you getting the concept of stack (data structure) wrong? You may get a clearer picture of how stack work at [URL="http://en.wikipedia.org/wiki/Stack_(data_structure)"]http://en.wikipedia.org/wiki/Stack_(data_structure)[/URL] Still, I could not figure out your example. Would you mind giving a clearer explanation?

Member Avatar for chiwawa10
0
134
Member Avatar for schoenfelder.p

Did you try to access your month, day, year variable directly from outside the class? Whats the error that you get? Please note that your month, day, year variable are declared as int but your accessor methods are returning double. (this does not flag an error but it is not …

Member Avatar for Ketsuekiame
0
148
Member Avatar for sparkle_jam

Your code should look like below if you want to return all balance for an account. [CODE] int userInput = 0; cout<<"Please enter the account number you would like to search"<<endl; cin>>userInput // iterate through all accounts to find for(int i=0; i<10; ++i) { // check if account number found …

Member Avatar for sparkle_jam
0
129
Member Avatar for Sargam541

Reference to read text from file [URL="http://www.cplusplus.com/doc/tutorial/files/"]http://www.cplusplus.com/doc/tutorial/files/[/URL] Use getline() to read one line at a time into a string Then, use find() of string class to check if the text is found [URL="http://www.cplusplus.com/reference/string/string/find/"]http://www.cplusplus.com/reference/string/string/find/[/URL] Post your code attempt in here and many people are more than happy to help you out.

Member Avatar for chiwawa10
-2
83
Member Avatar for Euphan

I do not think you can do that. A pointer of list pointing to a queue. That should not be compatible. Btw, what is the compilation error message that you get?

Member Avatar for griswolf
0
170
Member Avatar for kashimushi

A simple search in any search engine would have presented the answer to you. You may want to refer to this site for some reference [URL="http://www.cplusplus.com/doc/tutorial/files/"]http://www.cplusplus.com/doc/tutorial/files/[/URL]

Member Avatar for chiwawa10
0
87
Member Avatar for Leppie

Have you run your program and verified that the result is as intended? Will the program ever complete running? There shouldn't be any problem with the code you posted.

Member Avatar for Leppie
0
116
Member Avatar for Martje

Why would you want to initialize your const variable in the constructor class? Since they are constant and you know the values beforehand, isn't better to assign the value to your const variable at the point they are declared?

Member Avatar for mrnutty
0
85
Member Avatar for bhosle

There are only two possibility that your program does not close by itself. 1. You are running in Debug from IDE and the IDE prevents the console from closing 2. Your program is in an infinite loop Just build a release version of your program and run the built exe. …

Member Avatar for chiwawa10
0
116
Member Avatar for jsphb9000

Since you are reading from the stdin, you should use the function gets(char *str) which reads from the stdin and does not include the new line character (\n) in buffer

Member Avatar for Aia
0
177
Member Avatar for cokaznsyco72

Problem is not with the code you posted here. I suspect it is a syntax error that occurs before the myprintf() function. Do check your code before that, specifically the print_str() function.

Member Avatar for jephthah
0
197
Member Avatar for deanus

Never ever try to access a memory location like that. You have no idea what's stored in that memory location. Anyway, how did you come up with that particular number of 0x378? The purpose of pointer is to reference a memory location where it holds a value of interest to …

Member Avatar for deanus
0
227
Member Avatar for ARKaMAN

Assuming you want it to loop indefinitely (beware that this causes your program not able to end) [CODE] while(true) { // your codes here Sleep(2000); // milliseconds } [/CODE]

Member Avatar for Ketsuekiame
0
192
Member Avatar for ramakrishnaramk

First of all, your file should be written in binary which contains nothing but the objects of your c structure. Here's a breakdown of what you should do: 1. Open the file in binary format and read to the end of the file. Make sure the size is correct (correct …

Member Avatar for jephthah
0
101
Member Avatar for mr.confused!

Whenever possible, try to avoid nested loop as they have a worst-case of O(n2) - Big O n square. In simple terms, it has bad processing time because your worst case for nested loop is n square iterations. When your n is sufficiently large, your logic will take a very …

Member Avatar for jephthah
0
146
Member Avatar for pinkey
Member Avatar for chiwawa10
-2
317
Member Avatar for Akatosh

You must use 'delete' on every 'new' variable. Thus the second is one to follow. It is a good practice to make your pointer to point to NULL after you have deleted the object to prevent your pointer pointing to unspecified location. [CODE] void SomeClass::someMethod() { AnotherClass *object = new …

Member Avatar for WilliamHenry
0
141
Member Avatar for krap_nek

Yes, as demonstrated by Aia, you do not need to deal with incrementing pointers yet. You may pass in the address of a particular CITIZEN object [CODE]display_cit(&cit[x]);[/CODE] Then create a pointer as parameter to be able to access the passed in object's value [CODE]void display_cit (CITIZEN *individual)[/CODE]

Member Avatar for UncleLeroy
0
169
Member Avatar for defender_

I your case, I do not see why is there a need for you to create a list of pointers. Why not consider having a list of the object node and only maintain one pointer to your list? Ain't it more efficient?

Member Avatar for defender_
0
68
Member Avatar for iammfa

If all you want is to select the maximum and minimum, only one iteration is sufficient. 1. First assign the first element of array as min and max. While iterating, 2. compare if the current value is less than min. If yes, replace the min value 3. compare if the …

Member Avatar for chiwawa10
0
165
Member Avatar for swarnnim

To move through a linked-list, you will need an iterator. In your case of deleted every third node, simply use a counter which will increment after traversing each node. Delete the current node when your counter reaches the value 3. Then reset your counter to 1 upon iterating to the …

Member Avatar for sourabhtripathi
-1
85
Member Avatar for 3cats

In addition to thelamb's explanation, that means you have to remove the type name in line 33 and line 34. Also, remember to remove the '&' (address of) symbol. If you were to include this symbol in the caller function, pointers have to be declared as your function's parameter. For …

Member Avatar for 3cats
0
223
Member Avatar for empror9

Why not think about the logic. Do not worry too much about the syntax and things. Try to present your logic here and I believe many of us here are more than happy to give you guidance in turning the logic into codes.

Member Avatar for batchprogram
0
121
Member Avatar for bbrradd

In your find function, add a line to return -1 after the for loop. This will indicate ID not found/invalid ID. Then in line 23 after you get the value for variable [B]place[/B], add this checking: [CODE]if (place == -1) { infile >> id; continue; }[/CODE] This will skip the …

Member Avatar for bbrradd
0
110
Member Avatar for Uni616

[QUOTE]I then insert the edge into a min-heap. But, like I stated above the parse code works in NetBeans and Dev c++, but it doesnt work properly in a linux terminal.[/QUOTE] What do you mean by the statement above? Are you trying to compile your code using GCC in Linux? …

Member Avatar for VernonDozier
0
115
Member Avatar for viziroth

viziroth, I'm quite confused as to what you are asking here. I believe your question can be simplified. Do point out what you want to ask and make it clear. Thanks.

Member Avatar for caut_baia
0
209
Member Avatar for Hidden_mistakes

To start things off, why not you post some logics about the code that you have implemented?

Member Avatar for 0x69
0
78
Member Avatar for mattloto

It is better for you to implement your own. As written in [URL="http://www.cplusplus.com/reference/algorithm/find/"]std::find[/URL], if value is not found, the last will be returned. In this case, when the last index is returned, you cannot tell if the last item matches OR it is not found in your list.

Member Avatar for david.k
0
177
Member Avatar for nille_nerholt

Have you singled out that the slow performance is due to the sort operation? I suspect that the slow response may be due to the repainting event as highlighted by nille_nerholt. Do you mind to share with us what sorting algorithm are you using? Have you tried to use the …

Member Avatar for david.k
0
359
Member Avatar for karthz85

The variables you're storing to the TXT file [B]code, no_of_parts, sum_assignment[/B] does not contain any value. Those values stored in the function store_data() is locally-scoped. Meaning, they are accessible only inside the function. Therefore, even if you declare the same variable name in your function Save(), the application is not …

Member Avatar for chiwawa10
0
131
Member Avatar for acerious

A little piece of advice: [B]do put all your variable declarations at the beginning of the function[/B] It helps a lot in terms of readability and program maintenance in future.

Member Avatar for chiwawa10
0
131
Member Avatar for naseerhaider

A switch case inside another switch case is strictly a no no. It goes to show that your program is not modular enough. You'll have a hard time maintaining it. Others will have a hard time understanding the logic. [QUOTE=caut_baia;1201091]:) yeah i omitted the "&&" [code] char letter; char currency; …

Member Avatar for chiwawa10
0
135
Member Avatar for eggberto

Your variables are confusing. The [B]scrpt[/B] and [B]scpt[/B] seems to be used incorrectly. In the myfunc(), you are not accessing the passed in parameter. And why are you passing in the global variable instead of [B]char scpt[10][200][/B]? There is no need to pass global variables around. I would advice you …

Member Avatar for sdsda
0
169
Member Avatar for jksdua
Member Avatar for phummon

Yes, I agree with mbulow that you can use a std::map. You may also want to consider the option of 2D array since the number of fruits supported in a cart is known at compile time.

Member Avatar for phummon
0
133
Member Avatar for 3cats

You are getting the compiler error because the variable [B]bAmount[/B] is printed out in line 40 before it is assigned to any value. In that case (line 40) the correct variable should be [B]AmountDue[/B]

Member Avatar for chiwawa10
0
159
Member Avatar for d3mos
Member Avatar for chiwawa10
0
103
Member Avatar for Schrödinger

You may want to use the modulus (%) operator for getting the index of vector to delete. All you have to do is keep adding the [B]position to delete[/B] entered by user. Hope this helps

Member Avatar for Schrödinger
0
91
Member Avatar for Stefano Mtangoo
Member Avatar for Prat123
Member Avatar for jprogram

The main reason your program fails is because you are trying to read from your output file. You should be reading from your input file instead. [CODE]ofstream outFile("source.txt", ios::out); a1.prepare(inFile2, outFile); ifstream inFile3("encrypted.txt", ios::in); char ch; while(inFile3.get(ch)) { a1.encode(ch); }[/CODE]

Member Avatar for vidit_X
0
194
Member Avatar for shrutinr

Not sure if this is what you're looking for. You can check out MDI (multiple document interface)

Member Avatar for chiwawa10
0
71

The End.