2,827 Posted Topics
Re: Does it compile on another compiler? Could be some specific option in Visual C++ that needs to be changed in the linker or whatever. Hard to say. Or it could be in the code itself. Posting the code would help. People (i.e. me) can try to compile it and see … | |
Re: [QUOTE=NinjaLink;571306]Hello, I am doing a file input/output. I wrote 3 fulls names, phone number, balance. etc inside my input file. Example: John Doe 555-555-5555 5000.00 In my output file, I am trying to create this output with using setw. First Name Last Name Phone Number Balance ------------ ------------ ----------------- --------- … | |
Re: Just a guess, don't take this as gospel, but possibly the compiler is setting aside 384 bytes since 384 is a multiple of 4 and 382 isn't and for efficiency purposes, in a 32 bit system, the compiler only delegates memory in multiples of 4 bytes (4 bytes = 32 … | |
Re: So you are running a simulation, right? You're not supposed to calculate what the Poisson/Exponential distribution predicts it is supposed to be and approach it from a Statistics/Probability Theory viewpoint? Just straight random number generation of customer arrival and service times? No standard deviations and all that fun stuff from … | |
Re: [QUOTE=TheOneNOnlyQ;566337]1st off, Im new to C++ programming. I created a function to calculate garage parking charges. I keep getting this last error: HourFee.cpp(65) : error C2065: 'ROW_SIZE' : undeclared identifier this is my error ---> ***int vehicleInfo[ROW_SIZE][COLUMN_SIZE];*** [/QUOTE] You have a brackets problem here: [code=cplusplus] for (x=1; x<=10; x++) const … | |
Re: I don't see where the counters array is being used. Can you point to the line number? [code=cplusplus] #include <fstream.h> #include <stdlib.h> int i, j; int matrix[10000][5] = {0}; //Define a matrix with a maximum of 100 rows and 6 columns int counters[2][2] = {0}; // Define the genotype counter … | |
Re: [QUOTE=Jboy05;570924]I need help Fixing this I traced through the code, and it compiles not error but when I run the program its just goes crazy I need help finding a the soultion to this problem please Thank you very much [CODE]#include <iostream> #include <fstream> #include <cstdlib> using namespace std; int … | |
Re: [QUOTE=sisi;570349]I have to write a programme using loop struture to calculate the following formula r=1/x+1/2x+1/3x+......+1/nx . The user can input any interger for n and nonzero for x .[/QUOTE] What part are you having problems with? Post what you have. | |
Re: [QUOTE=jimJohnson;570062]i know that is something I am still working on...could that be the reason for all the errors?[/QUOTE] You need to comment lines out that are only half-complete because it can play havoc with the compiler. [QUOTE=Traicey;570077]What I cant seem to understand is that in ur [B]if[/B] [B]statement[/B] u have … | |
Re: You haven't told the compiler that "head" has anything to do with the PhoneBook class, so it doesn't know to look there. Perhaps you meant pb.head instead of head? Since pb is of type PhoneBook, the compiler knows to look for a data member of the PhoneBook class called "head". … | |
Re: [QUOTE=kilermage;568323]I get an error about "orphaned case". So this is the error. Can you help me on what I did wrong? [ICODE]client.java: 8643: orphaned case case 117: // bank 5 items - sell 1 item ^[/ICODE] This is the code: [CODE] case 117: //bank 5 items - sell 1 item … | |
Re: [QUOTE=amroto;567358]this is what i did in case 1 but i didn't work also: [CODE]case 1: outfile.open (myFile.c_str(), ios::app); char text[255]; cin.getline(text, sizeof(text)); cin >> text; outfile << text; outfile.close();continue;[/CODE] i really tried to search also for the other cases but i can't figure any out....this is f.y.i a self studying … | |
Re: What in particular are you having difficulty with? What functions to put in which files? How to include the files so they can be called by main? What libraries to use? How to write the functions themselves? How to call them? What? | |
Re: [QUOTE=DOrmisher;568907]I was wondering if anyone could help me with this little problem. What I am actually trying to do is implement 'picking' into a game I'm doing, but I'm actually stuck with some of the maths, thats why this isn't in the game forum. I'm trying to work out a … | |
Re: I would put in some code at the top of the actionPerformed function that displays a message saying the program is inside actionPerformed. Or you can add a breakpoint and do the same thing. If it doesn't get inside the actionPerformed function, then the problem is not there. If it … | |
Re: I'd post the output too. You're going to get fewer takers if they have to open up a file. It's not too long. You're given at least one function header, as well as a call to it. At the least, stick that function header at the top, write a function … | |
Re: Well, I would rename the tictactoe function "DisplayBoard" or something. I would add a function called "PlayGame". main would call "PlayGame". PlayGame would call DisplayBoard initially, then after every move. PlayGame would initialize the 2-D board to empty spaces, then pass to DisplayBoard. I would define the board array in … | |
Re: Depending on the libraries, Dev C++ comes with most of the libraries already. They are installed in the correct place when Dev C++ installs. try this: [code=cplusplus] // HelloWorld.cpp #include <iostream> using namespace std; int main () { cout << "Hello World!" << endl; getchar (); // pause return 0; … | |
Re: You should probably have at least a default constructor in the public section of your class (and a destructor wouldn't hurt either). You are going to run into trouble in line 40 in the code you posted. You are trying to store data in a char*, but you have not … | |
Re: [QUOTE=look@me;568099]my problem is i cant output the right answer[/QUOTE] You don't know how to get input from the file? You don't know which algorithm to use to solve it mathematically? You don't know how to take your mathematical algorithm and turn it into a C++ function? You don't know how … | |
Re: [QUOTE='Run.[it];568085']Weve been given this example to work with and Im not sure about the line 9 [B][I]char cont = 'n';[/I][/B] - is there even a need for it? The rest of the program I understand. [code=c++] #include <iostream> #include <stdio.h> using namespace std; int main() { int no = 1; … | |
Re: Code tags. And don't add the numbers. The code tags will do that: [noparse] [code=cplusplus] // paste your code here [/code] [/noparse] [code=cplusplus] int circle_x, circle_y, circle_radius, square_x, square_y; int x_y_square_coordinates(int circle_x, int circle_y, int circle_radius, int& square_x, int& square_y) { square_x = circle_x-circle_radius; square_y = circle_y-circle_radius; return square_x, square_y; … | |
Re: Begin by writing, on paper, what you want your program to do. What do you want the input to be, what do you want the output to be, what is legal data, what is illegal data? Decide whether you need to design a class or a struct, and if so, … | |
Re: [QUOTE=agenthobbs;567721]I am creating a program to manipulate structures that are similar to linked lists. The problem i am having is in a text file that i am reading in there are delete lines like this. d 1 2 d 2 3 d 3 4 d 2 0 with the first … | |
Re: I see some potential problems in the "if" statements where you were using = instead off == in places. You say there's only one error now and that you've made revisions, so it may be good to post your revised code along with the error and the line number. ![]() | |
Re: I assume this didn't compile. I'm not clear what goes with what, whether there is supposed to be a header file or an implementation file, or one big file, or what. At the very top, you have this code: [code] void account::withdraw(int amount) void account::deposit(int amount) int account::balance(void) [/code] Is … | |
Re: I would name the Panel class something different since there is a Panel class in Java already. [url]http://java.sun.com/j2se/1.3/docs/api/java/awt/Panel.html[/url] What object exactly do you want to have a mouseListener attached to? A button on the panel? The Panel (again, possibly rename this class if it is not the Panel class from … | |
Re: [code] Inventory3.java:104: cannot find symbol symbol : variable Product [/code] The key word above is "variable". The compiler is looking for a variable. Product is not a variable, it is a class: [code=JAVA] class Product implements Comparable [/code] You are using it as a variable by comparing it to the … | |
Re: This is one of the stranger threads I've read on this forum in a while. O.K., let's say you actually created this virus and released it and it's already on a bunch of computers doing whatever bad things it does. Let's say you succeed in writing the anti-virus to wipe … | |
Re: I got this output when I ran your program: [code] Welcome to DVD Inventory 1.0 Item #: 502 Name: Abyss Quantity: 25 Price: $12.95 Value: $323.75 Item #: 1003 Name: Deep Impact Quantity: 65 Price: $21.95 Value: $1426.75 Item #: 750 Name: Forest Gump Quantity: 28 Price: $7.95 Value: $222.6 … | |
Re: Visual Studio just came out with their 2008 editions. The Express editions are still free and I imagine have improved over 2002, especially since you say you are going with Vista. Dev C++ is always free. Code Blocks is free. And NetBeans has a C++ option that allows you to … | |
Re: Code tags and formatting will make your code easier to read: [noparse] [code=JAVA] // paste your code here [/code] [/noparse] Without using code tags, if you had any formatting to your code, it will be lost when you post it here. As far as returning to the top if the … | |
Re: [QUOTE=zargare;566495]Hi, Can any one tell me where I can find information about data files? And I am trying to find answers for the following questions: Is there a specific structure for the data file that I use in C++? What is the best way to write a data file for … | |
Re: [QUOTE=perseus150;566330]I am having trouble creating an inverted half-square out asterisks. The problem requires three nested for-loops, I believe, but am unsure as how to proceed. Here is the work I have so far, with the UN-inverted half-square code in [I]italics[/I]. The inverted portion should be a simple manipulation of that … | |
Re: If you are going to use i as a counter, don't pass it your function. Rather, declare i inside your function. Seems to me that you want to pass your function the length of the array that is to to be swapped: [code] void reversing (char p[], int lengthArray) { … | |
Re: I think you have your loops inverted here. The outer loop control variable should be incremented by 1 each pass through the outer loop. The amount the inner loop increments should vary. You have neither varying. You increase i by 2 each time since incr never changes, and you increase … | |
Re: [QUOTE=Ryano24;563456]Do you mind showing me an example of using de morgans law since I am a beginner.[/QUOTE] [code] (A && B) = ((A') || (B'))' [/code] A and B are anything that can be true or false. ' is the "complement" operator in math. If A is true, A' is … | |
Re: [code=C] #include<stdio.h> #include<stdlib.h> #include<time.h> int main(void) { int runagain=0; srand(time(NULL)); int randnum=rand()%100 +1; int guess=0; do{ printf("Enter a number between 1 and 100\n"); scanf("%d",& guess); if (guess<randnum) printf(" to low enter higher number"); if (guess > randnum) printf("to high enter lower number"); if(guess==randnum) printf( "You got it!\n"); printf("wolud you like … | |
Re: [QUOTE=Danii;562645]Hi what is the difference between the following two code public int calculate(int x, int level) and public int calculate() int x; int level; Is there a way to make this first method to something like the second method? thanks[/QUOTE] The second one doesn't make any sense to me. This … | |
Re: [QUOTE=dkwantee;562115]Hello! i have the following data in a file student_id student_name maths_score english_score physics_score can i use a nested structure to read the file? [CODE] struct student { int id; char name[40]; }; struct score { int maths; int english; int physics; }; [/CODE] if yes, how will i read … | |
I'm pretty sure the answer is a definite no if it is a pointer to a primitive type, but I have created classes called "network", "path", and "node" and I want them all to be able to refer to each other. These are not primitive types, so I hope I … | |
Re: [QUOTE=Crazycfk;560540]i am doing a decimal to binary conversion and i have figure out how to do the conversion i just don't know how to make it cout so that it is in reverse.... i was also told that it could done in a while loop here is the code [code] … | |
Re: [QUOTE=Moporho;561067]Exactly! I think I am suppose to create a counter stating the times it goes through the loop using each function. So I will eliminate the first counter because I do not need to see the number of primes between 2 and 10000. I do need to see how many … | |
Re: How about using the "find" function in the string class to search for an occurrence of "Number2["? I think you are on to the same idea with rfind. find will return the index of the 'N' in "Number2[". Add the number of characters in "Number2[" and you are at the … | |
Re: [QUOTE=digital_ice7;560792]how do i convert int to char... int x[10]; char y; ???????[/QUOTE] Not sure what you are trying to do here, but if you have an integer from 0 - 9 (a single digit), you can convert it to a char by adding 48 (which is the ASCII value of … | |
Re: [QUOTE=henpecked1;561371]Still no workee, it's still interpreting the Y as the last name, and still, if you enter anything but Y, it quits the program. Here's the results [COLOR="Red"] Please enter your last name up to 15 characters me Please enter your first name up to 15 characters me Please enter … | |
Re: In situations like this I always look at the "static" aspects of my code first and try to get rid of as much "static" code as possible. I would create a constructor and stick most of my code from "main" into that constructor. I've never been all that great at … | |
Re: You don't want these functions inside your main function. Try designing your program like this: [code] // code to include libraries using namespace std; // function prototypes int main () { // code for main } // Put functions here [/code] | |
Re: [QUOTE=redZERO;561204]Okay, I've downloaded JDK, but when I try to run the command in DOS, it says that it is not a recognized command or something like that. I have read a bit about editing the PATH variable, but now everybody is saying that there are 2 ways to do this, … | |
Re: Use code tags and it'll be easier to read: [noparse] [code] // paste your code here [/code] [/noparse] or [noparse] [code=JAVA] // paste your code here [/code] [/noparse] The second of the two above ends up looking like this (after formatting through NetBeans): [code=JAVA] import java.util.Scanner; // program uses class … |
The End.