107 Posted Topics
Re: fmax takes only two variables as input. So you can only use fmax(a,b) For three variables a,b,c use something like [CODE] d = fmax(a,b); e = fmax(c,d) [/CODE] e will be the max of a,b,c | |
Re: You have followed some thinking process to arrive at the answer, right? Now convert this into pseudo code and finally code. If you post atleast the pseudo code here, you will get some help. | |
Re: You could consider [URL="http://www.cplusplus.com/reference/clibrary/cstring/strtok/"]strtok[/URL] instead of sscanf. I hope the large sized arrays are justified. You could end up corrupting your stack. | |
Re: I have seen this problem before of large arrays on stack. Just declare it as a global. | |
Re: Please take a look at how the [URL="http://cplusplus.com/reference/string/string/c_str/"]c_str[/URL] function is used. | |
Re: Welcome to the club!! However, it is fairly easy to identify SEG faults once you can competently use a debugger. Compile with -g option to use binary with debugger. There are some cases where even the debugger can't help you. Thorough analysis of the code only can help you there. | |
Re: You are having a problem in line 32-36. Instead of iterating through the linked list and adding your element at the end, you are pointing your head node to the new node and the new node points to your head. All the intermediate nodes are lost. You are left with … | |
Re: Move curly brace from line 60 to line 28. As it is all your functions are implemented inside main. Remove the semi-column at the end of lines 29,37,42,47 & 52. these are implementation signatures. Change the returns as previously suggested. Add a line to do the operation first and then … | |
Re: Are you allocating memory to Index? I can see "Index[Counter] = new" But I don't see "Index = new" anywhere or it's equivalent. | |
Re: I would like to see Event.h Can you please upload the same? Also, posting in bits and pieces of code is most irritating. You are posting it because you don't know what the error is. Then how do you expect yourself to understand what part of code is causing the … | |
Re: Issue is with your while loop. It was not exiting properly. Change [CODE]while(!myFile.eof())[/CODE] to [CODE]while(getline(myFile,line))[/CODE] and comment out the getline inside the while loop. (no need for two getline function calls) | |
Re: Spelling mistake at 64 [CODE]Employee::Employee()[/CODE] 70,71 [CODE] firstName = first; lastName = last;[/CODE] You are assigning a character to a character pointer. An approach would be to change this to take char pointers as input and use a string function to copy. Allocate memory for the pointers in the constructor. … | |
Re: Change the getmax implementation as [CODE]template <class T> T pair<T>::getmax (){[/CODE] In main use [CODE]pair<int> myobject(100,75);[/CODE] Also rename pair as pair1, as there is a naming conflict in std namespace. (else remove using and use std:: as required) | |
Re: First of all you are passing radius to calcPrism and calcPyramid. In those functions, the calculation is not based on radius. The compiler fails to give any error , because you have the length,height and width defined as globals. | |
Re: Try using a debugger like gdb to identify the exact crash and the reason. | |
Re: Take a look [URL="http://www.cplusplus.com/doc/tutorial/files/"]here[/URL]. | |
Re: Check whether your stream is open using [URL="http://www.cplusplus.com/doc/tutorial/files/"]is_open().[/URL] Use [URL="http://www.cplusplus.com/reference/std/iterator/istream_iterator/"]eos[/URL] as the exit criteria for the istream_iterator. | |
Re: In C++, arrays start from index 0. In your case that would be row 0 column 0. Not sure what you mean by entry point. Do you want to start from row 1 column 1? '=' is not a comparison operator. It is an assignment operator. | |
Re: Have you tried using strcmp instead of == in the if check? | |
Re: From your explanation, it looks like the problem could be the getVal function. Could you try and re-write the for loop in getVal so that there is a proper exit condition here? [CODE]for (j=0;nent--;j++) [/CODE] I am not having access to a compiler and hence can't say whether it is … | |
Re: Post your whole code or attach it as files. | |
Re: The functions num and results have been defined initially with no arguments. In function main, those functions are called with no arguments. But, while implementing the functions, arguments are present. The linker is trying to look for the functions called in main. Since it is not able to find the … | |
Re: First of all let me apologize that I cannot give too much attention to your problem. But the first thing that I would do would be to rename my Polygon class, since it looks like there are two classes with the same name. Another thing that could be done would … | |
Re: Is [URL="http://www.creativecrash.com/downloads/applications/os-utils/c/unix-commands-in-windows"]this[/URL] what you are looking for? | |
Re: Reading your problem statement makes no sense, what exactly is the problem that you are facing? | |
Re: [CODE]int succeed = ParseCommandLine(buf, data*);[/CODE] The above line does not make sense. You want to pass the address of data to the function ParseCommandLine. So the code should be [CODE]int succeed = ParseCommandLine(buf, &data);[/CODE] | |
Re: You might want to consider changing [CODE]c= n[/CODE] and [CODE]r= m[/CODE] with [CODE]c== n[/CODE] and [CODE]r== m[/CODE] | |
Re: What error are you getting? From looking at your code it looks like [CODE]Action();[/CODE] the above way of defining your default constructor could be the problem. If you would post the actual compilation error, I would be able to help you better. | |
Re: Write the data to a temporary file and rename it as fruit.txt | |
Re: try using [URL="http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/"]sprintf[/URL] | |
Re: Hope [URL="http://www.keil.com/support/docs/697.htm"]this[/URL] article helps. | |
Re: [CODE]memcpy(root->message,&in_rec,s_siz); memcpy(temp->message,&in_rec,s_siz); [/CODE] You need to allocate memory for the message as well. Otherwise you can make message a non pointer variable. [CODE]struct host_msgs_list { struct host_msgs_struct message; struct host_msgs_list *next; }; [/CODE] | |
Re: You could either modify the for loop reading the stream to regulate it to read only till EOF or add more elements to your data file | |
Re: try[CODE] itemTotal = total; itemPrice = price; [/CODE] instead of [CODE] setItemTotal = total of cars; setItemPrice = price per car; [/CODE] | |
Re: use [CODE]yOn = scn.next();[/CODE] instead of [CODE]yOn = scn.nextLine();[/CODE] at 196 | |
Re: There is no need to beg. Looks like [CODE]void div(){[/CODE] is not getting closed. Put one more curly brace before main() [EDIT] use [CODE]int main()[/CODE] | |
Re: The second link given by BJSJC gives you most of the info required. Check out the below link as well. [URL="http://java.sun.com/docs/books/tutorial/2d/printing/printable.html"]http://java.sun.com/docs/books/tutorial/2d/printing/printable.html[/URL] | |
Re: If you want more information of design patterns it would be a good idea to refer to a book like HeadFirst. I am sure that googling also would result in a good number of sites giving details of all the design patterns out there. The basic idea of singleton is … | |
Re: In the while loop that you are using for printing why don't you do an strstr and extract the value that you need? Something like [CODE] strstr(result, "SRC="); [/CODE] | |
Re: You are referring to two different functions in your code. a_star and a_start. Try renaming them to the same name. Ex: a_star is defined at line 26. a_start is implemented at line 179. Rename them both to a_star and modifying your function calls also should help. | |
Re: You should be using [CODE]#ifdef fst[/CODE] in your code check instead of [CODE]#if (fst == 1)[/CODE] [CODE]#define fst 1 [/CODE] The above line is an indicator to replace fst with 1 whenever seen. So (fst == 1) translates to (1==1) The #define is used for many purposes like , 1)For … | |
Re: Have you tried using sprintf to print the hex formatted numbers onto a string. | |
Re: Why should 10.1 be greater than 10.5? Can you add your code to the post so that there is more clarity? | |
Re: I haven't gone through either the problem or the solution. But I have a query. Why are you printing out the address of the returned variable. In printf on line 24, shouldn't you be printing out life_test instead of &life_test. | |
Re: Putting a break at the end of each case statement should work. [CODE]case 4: printf("Enter the bank's rating: "); scanf("%s",rating); printf("%s\n\n", rating); break; [/CODE] | |
Re: try copying the following line at the top of your file [CODE]#define _GNU_SOURCE [/CODE] | |
Re: The code compiles if you make the below changes [CODE] JTextField T1,T2,T3,T4; JPanel P1; JPanel P2; JPanel P3; public BodyMass() { P1=new JPanel(); P2=new JPanel(); P3=new JPanel(); [/CODE] Enclose your multiple statements after if and else in curly braces. An example: [CODE]else if (n.equals("ORANGE")) { P1.setBackground(Color.ORANGE); P2.setBackground(Color.ORANGE); P3.setBackground(Color.ORANGE); } [/CODE] … | |
Re: You could try giving the prototype of the function at the start of the program. [CODE]void Wander(double *forwardSpeed, double *turnSpeed); [/CODE] Kindly use code tags while posting code.. | |
Re: Check whether you are closing the file after opening it. In most cases you will need to open the file only once. (depends on your requirements) Can you copy your code here? |
The End.