318 Posted Topics
Re: The problem lies in your main method. You cannot concatenate strings using + in c++. You simply use the << operator again. [CODE]cout << "Manufacturer's Name: "<<t1.getManuName();[/CODE] | |
Hey, I'm not too sure what the problem is here, I have never had trouble using fscanf before. The following shows the code I use to check the file, and the result. [CODE]while( true ) { int vals_read = fscanf(fileHandle,"%[^;];%s",&name,&pass); if( vals_read == 2 ) { // process the line … | |
Re: 1. Think of a structure that you could use to store a number of rows and columns of "something" 2. Make sure the number of mines cannot be larger than that structure. 3. Think of a suitable way to display your board. i.e. a mine as a * symbol etc. … | |
Re: What do you mean by an unordered linked list of classes? I don't understand that bit. I think you mean objects? To "get" objects from a linked list, I suppose you mean, how to access the data at a particular node? What you usually do, is create a separate iterator … | |
Re: [QUOTE=ichigo_cool;1524689]Thanks for helping, I found the solution, all I needed to use was default variables so I don't need to pass in any arguments from main[/QUOTE] If you don't need to ever enter paramaters, then just setting the values in the constructor will do, setting all params to default is … | |
Re: [QUOTE=DarKKendO;1524739]the assignment basically gets us to write a basic Linked list so that we better appreciate the underlying structure. I think I've got it sorted now though. The problem was that I wasn't declaring an instance of the object in the main method. I added DictionaryTree test; as the first … | |
Re: [QUOTE=Fbody;1502726]I really don't see anything wrong with the lines you have mentioned as suspects for the problem. They all appear to be properly-written output statements. Your issue is is actually an input issue. It's caused by the input stream getting corrupted. What is struct emp intended to represent? It looks … | |
Re: Have you seen the videos on this link: [url]http://xoax.net/comp/sci/algorithms/[/url] It is explained visually, which is much easier to grasp. | |
Re: Is this what you need? [CODE] #include <iostream> int main(int argc, char* argv[]) { std::cout<<"Hi!\n"<<std::endl; std::cout<<"enter 15 integers in the range of 1-20.find how many of these values fall in the range of 1-50, 51-100, 101-150 and 151-200.Validate the input so that only values from 1-200 will be entered."<<std::endl; for(int … | |
Re: Have you even tried to compile this/test this before posting here? | |
Hey, I am having trouble trying to set a default value for a function in one of my classes. Here is where I am trying to set it: [CODE] void Sprite::Spr_Blit(SDL_Surface* source, SDL_Surface* dest, SDL_Rect* clip = NULL) { SDL_Rect offset; offset.x = getX(); offset.y =getY(); SDL_BlitSurface(source,clip,dest,&offset); } [/CODE] Here … | |
Hey, I am starting to work with SDL and I had it all set up correctly etc. The thing that does not seem to be working correctly is the SDL_ttf. Now, As far as I am aware, linux builds don't use truetype, which is why I am at a loss … | |
Re: It would help if you actually asked a question. | |
Re: 1000 lines of code, and you ask how to fix it? Have you not tested your program as you wrote the thing? Please come back when you have a snippet of your exact problem. This isn't your personal debugging community. | |
Re: You wouldn't normally have both the declaration and initialization of TextFields etc in the same method. Most of the time, you would declare all your forms controls etc as global variables. Then call some initialise method from your class constructor. The way you did it, your JTextFields are local to … | |
Can't believe it has gotten to this. I cannot for the life of me figure out what is messing up my desired outcome. Here is the story: I have a small GUI program for a sports club. I have 3 list boxes, 1 for each U10's,U12's and U14 children. I … | |
Re: You are not doing anything with the 3 lengths that you request from the user, You still need to use the methods you created. Also, on your first method you have not specified a return type in the method declaration, so that should cause a compile error. | |
Re: What is the point with this line? [CODE]if (X1>Y);[/CODE] | |
Re: At first glance, [CODE]static void Triple(int num 1, int num2,int num3 ) {[/CODE] this seems to be your only problem. You have separated the variable name in your num1 variable. You have num 1. ![]() | |
Re: Look at your cout statement: [CODE]"Current Price << setw(7) << "$P/L" << setw(7) << "%P/L"<<endl;[/CODE] Your Current Price string is running into your operator, and other numerous problems with this. Fix your "", throughout this line | |
Re: What is supposed to be "written underneath" is whatever code is necessary to make the method perform as you intend. E.g. If you want the method to return the sum of 2 numbers: [CODE] public int add(int num1, int num2) { int sum=0; sum = num1+ num2; return sum; } … | |
Re: [CODE]cout<<"_ _ _ 1"; cout<<"_ _ 2 2"; cout<<"_ 3 3 3"; cout<<"4 4 4 4";[/CODE] | |
Re: I'm not 100% sure what you are asking, but if you loop through your array, can you not check if an index is null, and if it is, ignore it? [CODE]for(int i=0;i<array.length,i++) { if(array[i]!=null) System.out.println(array[i]); } [/CODE] | |
Re: I do not understand your whole coding. How can it possibly work? 1. You have multiple declarations of the same varaibles, but with different types. i.e. int index1, int index2, String index1, String index2 2. You are trying to compare a String to an int. Which is not possible. while(Name!=Sentinel) … | |
Re: If you read the API docs for the Scanner class, you will see: Scanner's nextLine method "advances this scanner past the current line and returns the input that was skipped." Just replace nextLine() with next() ![]() | |
Re: This would be much easier for you if you use objects(create a student class). Then you can store all of your info in a single array, like masijade had suggested. [CODE]public class Student { ID; name; course; address school; public Student(ID,name,course,address,school) { } }[/CODE] [url]http://download.oracle.com/javase/tutorial/java/javaOO/[/url] | |
Hi, I am writing this template Array class. I am trying out some different functions, anything I can think of to implement. I have written an Add function as follows: [CODE] /**Add function - adds an element at the top of the stack**/ //creates new Array 1 larger //sets position … | |
Re: while(numb<=60)//means run this code while numb is in the range numb -> 60 inclusive Your increment numb by 2 everytime the loop runs. Therefore, once it reaches 60, and it will because you included it in your range, it will run again and therefore numb will be 62. What do … | |
Re: To add to what jon.kiparsky said, you will then need to create an instance of the class that contains the method you require: [CODE]FirstClass first = new FirstClass();[/CODE] inside the class you want to use it in, then call that method using the Class.getTextFromTextField1() syntax, where Class is the name … | |
Re: This is the Java section. Also, post your code in CODE-tags. Also, include the problem you are having plus any errors that you receive. You also haven't stated what a "Love Program" is, what is its purpose? Is it doing what you want? | |
Re: You are trying to use a java keyword as a variable name. Scanner new = new Scanner() does not make any sense. new is a java keyword. Change the variable name to something else. Here is a list of keywords which cannot be used as variable names [url]http://download.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html[/url] Also, [CODE] … | |
Re: Most probably because your screen is updating much slower than you can move the mouse. How often is your screen "redrawing"? | |
Re: On this line: [CODE] System.out.println("Key msg:" +setKey);[/CODE] Don't you mean: [CODE] System.out.println("Key msg:" +getKey());[/CODE] | |
Re: I hope you are a troll. Please, for the human race let you be a troll. | |
Re: [QUOTE=peter_budo;1466229]Do not forget to reference it in your report before you submit it...[/QUOTE] I have no idea why I was so amused by this! | |
Re: You can use the System.exit(0); function. It takes an int as an argument, and terminates the currently running JVM. [url]http://download.oracle.com/javase/1.4.2/docs/api/java/lang/System.html[/url] | |
Re: Well, if you put the call to displayData inside your input after your loop, then that part will work fine. You are getting the warning because you have no default return value. Just put return 0; at the bottom of your function. | |
Re: Maybe this will help you [url]http://homepages.gac.edu/~mc38/2001J/documentation/g++.html[/url] | |
Re: Ok, is this how your logic should read? [I]if the value of begllts is less than or equal to the value[m] inside the array [B]and[/B] the value of the position m of the array is less than or equal to the value of endllts, then do this{}[/I] Is that what … | |
Re: What is the second for loop for? You want to check if the value is found in the contents, so once you make the check [CODE]if (contents[i] == theValue)[/CODE] Then you should return true inside that. Then, at the end of your method, just return false(will mean the if statement … | |
Re: It is because you are passing it to your setName() method without actually taking a value! Try storing input.nextLine() in a separate String variable first. Then pass that new variable which contains the input into your setName method! | |
Re: String test = null? If you want to create an empty string use String test = ""; Not sure if that's where your problem lies. [CODE]textField.getString()[/CODE] Is this a JTextField? | |
Re: The reason for your boolean errors is you need to compare 2 values on each condition. Meaning, you can't have a condition such as: 65 < age >= 21. You are trying to compare age to 2 different numbers to one number at the same time. You need to separate … | |
Re: What was your meaning when writing these lines? [CODE] myA = new int[250]; myA[0] = 50; myA[1] = 50; myA[2] = 50; myA[3] = 50; myA[4] = 50; [/CODE] | |
Re: Well, string1.length returns the length of the string yes? lets say you enter: hello The length is 5(there are 5 letters). But, if you count the number of letters starting from 0, you get: 0,1,2,3,4... As you can see, even though there are 5 numbers here, the last number is … | |
Re: > Hi stultuske, > > While I appreciate your enthusiasm towards the rules of this website, perhaps you should actually read them: http://www.daniweb.com/forums/faq.php?faq=daniweb_policies Keep It Pleasant Do not post anything with malicious intent against another member, including, but not limited to, racist, sexist or religiously prejudiced remarks Do not post … | |
Re: [QUOTE][B]I'm not sure how to make a wall that cannot be passed through, could anyone help me? [/B][/QUOTE] There are different ways to use collision detection, but a basic way, using rectangles, is to use the rectangles bounds and position on screen. And make a check as to whether any … | |
Re: Using your old code, replace: [CODE]if (padding == "r") System.out.println(costRegPad); else if (padding == "d") System.out.println(costDlxPad); [/CODE] with [CODE]if (padding.equals("r")) System.out.println(costRegPad); else if (padding.equals("d")) System.out.println(costDlxPad);[/CODE] To compare Strings you use .equals | |
Re: Yes, what you are doing there is creating an array [I]where you can place 5 [B]employee objects[/B][/I]. To fill your array you will need to loop through it, adding a new Employee() and asking for input with relevant paramaters in its constructor each time. |
The End.