2,827 Posted Topics
Re: [code=cplusplus] #include<iostream> #include<fstream> #include<string.h> using namespace std; enum mediaType {CD, TAPE, MP3}; struct Song {char title[20]; char artist[20]; mediaType medium; float cost; }; Song *getData(ifstream&); void searchData(Song*[200], string, int); int main() { ifstream indata; indata.open("song.txt"); string artistName; Song *songs[200]; int x=0; cout << "Input Artist Name.\n"; cin >> artistName; *songs … | |
Re: Make sure you don't have any spaces in the code tags. [noparse] [code=cplusplus] // code [/code] [/noparse] Not this [noparse] [code = cplusplus] // code [/code] [/noparse] [code=cplusplus] void delete(string contacts[], string fName, string lName, ifstream& aInFile, ofstream& aOutFile) { cout << "DELETE A CONTACT\n"; cout << "Type the contacts … | |
Re: You need to use some C++ code tags so you get the line numbers, do some formatting so it's readable, and be more clear with your question. [noparse] [code=cplusplus] // paste your code here [/code] [/noparse] I think you need at least one more constructor: [code] Poly (double coeff[], int … | |
Re: [QUOTE=blaec;581465]I dont understand how to use: std::sort(strarray.begin(), strarray.end()); changing to if( ch >= '0' && ch <= '9') still gives me same result (underscore)[/QUOTE] I think you're going to have to post your updated program for us to understand what you have tried. | |
Re: So the first program creates biblio.txt and the second program is supposed to read from biblio.txt and fill in the missing data? What does biblio.txt look like? You may want to #include your class in your second program too. That would probably mean splitting that first file from one file … | |
Re: That's way too much to read without code tags and formatting. [noparse] [code] // Paste your code here. [/code] [/noparse] or [noparse] [code=cplusplus] // Paste your code here. Adds line numbers and syntax highlighting. [/code] [/noparse] | |
Re: [QUOTE=Black Magic;581437]Thanks, i'm just really mucking around atm but im going to make somethings like Elliot.setAge(81); in a minute or two :) Btw, can you tell me another alternative to system("PAUSE>nul"); Because pause nul gets rid of press any key to continue, What other solutions can i use? EDIT: Is … | |
Re: So if seats[1][3] ='!', that means that the 4th seat of the 2nd row is taken (adding 1 to array indexes to get row and column)? And that seat is available if seats[1][3] = 'U'? When a seat is reserved, it changes from 'U' to '!'? | |
Re: [QUOTE=knewc;581137]I know what recursion is sir...though thank you for your help!!! i just dont understand what output he wants...or what type of function he wants[/QUOTE] [QUOTE=knewc;581096]*EDIT* INTERPRET! lol....sorry! Write a recursive function array_sum(int *array, int size, int index) that computes the sum of all the elements of the array starting … | |
Re: DecimalFormat might come in handy here. [url]http://java.sun.com/j2se/1.5.0/docs/api/java/text/DecimalFormat.html[/url] Here is an example. [url]http://www.daniweb.com/forums/post101822-4.html[/url] | |
Re: Change > to < in your loops. You aren't going through them. | |
Re: I think you need to attach "home12.h" for us to be able to run it and help. Also, do you need to #include the "functions.cpp" file in main.cpp in order to call the "mystery" function from main? | |
Re: [QUOTE=Ancient Dragon;577376]Nobody is going to do your homework for you without pay.[/QUOTE] Looks like someone did. | |
Re: Decide where you want to put the buttons on the GUI, place them there, and add ActionListeners to them. Each new button represents a key that was pressed before. Decide which buttons go with which keys. Say a button called kButton was assigned to do the same thing as what … | |
Re: First off, cool maze program. I compiled it and ran it in Dev C++ and was able to manuever through the maze and have my character move in the direction I wished to what (I believe) is the goal (a hole in the wall on the right side of the … | |
Re: [code=cplusplus] #include <iostream> #include <iomanip> #include <algorithm> using namespace std; int main() { int i,num[20],n,j,choice,tmp; cout<< "Please enter 20 integers"; for (i=0; i<20; i++) { cout<<"\nEnter next value:"; cin>>num[i]; } cout<<"\n1.Display original data.\n"; cout<<"2.Sort the data into descending order\n"; cout<<"3.Display the sorted data (Only if you've already sorted)\n"; cout<<"4.Get the … | |
Re: [QUOTE=mussa187;577676]I am trying to check the input for 8 bit an unsigned integer.[/QUOTE] I don't understand what you are trying to do. What are you checking? | |
Re: Well this is the C++ forum. I'm sure you can do all of that in C++, though I have no idea how so I'm of no help if you go the C++ route. However, Java has the Swing library, which has a lot of these function written for you if … | |
Re: I'm trying to make sense of this. Can you post the Node struct and your declarations of the BaseStation variable and the arrayOfNodes array? | |
Re: [QUOTE=Kaushalya;576866]Wish you all a good day.Currently i'm working on c++ project.I want to know how to convert string object to a character array.Also why ifstream object doesn't accept a string variable as follows, void split(String filename) { ifstream ifile; ifile.open(filename);//this fails }[/QUOTE] A string already is a character array. See … | |
Re: This code is a prime candidate for a loop: [code=cplusplus] int c = 1; a[c++] = 16; a[c++] = 15; a[c++] = 14; a[c++] = 13; a[c++] = 12; a[c++] = 11; a[c++] = 10; a[c++] = 9; a[c++] = 8; a[c++] = 7; a[c++] = 6; a[c++] = 5; … | |
Re: I would imagine you could create a vector of char*. Go through your vector of integers, use itoa on each individual integer to create a string, then push that new string onto your vector. Note that itoa converts to a char*, not a C++-style string. itoa wouldn't work on an … ![]() | |
Re: The order that you are calculating is the order that you are displaying. This is because you are not storing earlier calculations. Data must be immediately displayed or it is lost. You need to do one of two things: Option 1: Set aside storage in an array, vector, or linked … | |
Re: [code=cplusplus] #include <iostream> #include <cstdlib> #include <string> using std::string; using namespace std; int main() { int random = rand(); int money = 100; int bet; bool correctbet = false; int Hcard[10]; int ccard[10]; string hroyal[10]; string croyal[10]; int totalace = 0; int totalace2 = 0; int numcards; int totalh = … | |
Re: [QUOTE=Megaz221;576654]Hi, I'm back again. Anyways, I have been working on a little project on my own. But I have a question about something. How would jumble characters in a string around. Let's say user inputs a word computer , the program then jumbles the characters in the string to mpcotreu. … | |
Re: [QUOTE=pship07;576458]I need to make a program to do the following: 1. ask the user for the name of the input file, and open/read it. 2. For each well-formed cout statement, i must execute it. For any malfunctioned cout statement, print an error message. the syntax of a well-formed cout statement … | |
Re: I ran this program in Dev C++ and got the same non-error: [code] #include <iostream> using namespace std; int foo (int a); void do_something (int a); int main () { int a = 5; int b = 10; b = foo (a); cout << "In main post call: a = … | |
Re: I remember once trying to call Java Swing functions from C++ code so that all the calculations could be done in C++ and the graphical stuff in Java Swing, and we never really got it to work. The two pieces worked fine separately, but C++ and Java couldn't communicate. This … | |
Re: [QUOTE=jimJohnson;574689]I have an exam tomorrow and just going over quizzes I did not do all that good in and was wanting to know if anyone could assist me w\ my mistakes Quiz 6 This question asks me to put in the output int Function_one(int y, int x); int main() { … | |
Re: Sure. [code=cplusplus] int numEndl = 8; for (int i = 0; i < numEndl; i++) cout << endl; [/code] | |
Re: I can only think of two ways to repeat the code in your while loop. One, another type of loop, like a for loop (though in this case a while loop seems to make a lot more sense) or through recursive calls to a function. I can't think of any … | |
![]() | Re: So it sounds like this is data that gets paired together. So you have something like this: [code] 1 R 2 B 3 F 4 W [/code] where 1, 2, 3, 4 are song numbers. And R, B, F, W are letters representing song type? And you want to randomize … ![]() |
Re: [QUOTE=demroth;572148]I have been reading the posts on radix sort here at DaniWeb and at [url]http://www.cubic.org/docs/radix.htm[/url]. I have already created the code for the counting sort which will do the rest but I do not understand how to do the radix part. I guess what I am asking is if you … | |
Re: Well I can't give it to you, but maybe I can point you in the right direction. Let's look at what the end result is and work backwards: [QUOTE] What you should hand in The following should be submitted to the Campus office in hard-copy form: * A listing of … | |
Re: Sorry to hear you have cancer. I wish you the best on that. That doesn't change the fact that you are acting like a complete jerk. You have no idea who sits at a desk all day, who doesn't, and who has been to Iraq and Afghanistan. That's all irrelevant … | |
Re: [QUOTE=Noliving;573734]I've come up with this now: [code=java]public static double power(double x, int n){ if (n == 0) return 1; else if (n > 0) return x * power(x,n - 1); else return (1.0 / power(x, Math.abs(n))); }[/code][/QUOTE] That seems like it should work to me. Pretty clever, actually. I've never … | |
Re: [code] void Bst<generic>::insert([COLOR="Red"] generic x[/COLOR]) [/code] x is type "generic". [code] struct Bsn { Bsn * p; Bsn * l; Bsn * r; [COLOR="Red"]generic * data[/COLOR]; }; [/code] data is type "pointer to generic". [code] if( m_root -> r == NULL && [COLOR="Red"]x[/COLOR] > m_root -> [COLOR="Red"]data[/COLOR]) [/code] You are … | |
Re: [QUOTE=ElectorCount;569976]i tried that and im confused as what to do with the array i created. Also, im using Microsoft visual C++ 2008 and it doesnt seem to like your code. Is there any specific thing i need to include?[/QUOTE] Did you put these lines at the top? [code] #include <vector> … | |
Re: It's called "typecasting". [code] int a = 5; double b = (double) a; double c = 4.0; int d = (int) c; [/code] chandra.rajat is correct in many cases. The compiler will figure out the typecasting above without being told and unlike Java, C++ doesn't demand all of the explicit … | |
Re: Here's the syntax of an if-statement: [code] if (condition) { // execute this code if condition is true } [/code] You have this: [code] if chChar == a; [/code] You need parentheses areound the condition and you need to get rid of the semicolon. | |
Re: You don't need a loop as far as I can tell. Just ask three questions in a row and assign the answers to the appropriate variables. You don't want the [20] in the code unless the last name, first name, and phone number are each only one character. If you … | |
Re: [code=cplusplus] #include<iostream.h> #include<conio.h> #define max 1000 //------------------------------------------------------------------------------ struct moto{ char gra[10]; rodzaj[10]; int rok_produkcji; }; moto game[max]; void main() { clscr(); cout<<"Podaj liczbę Gier których dane chcesz wprowadzic:\n";(from Polish Users message:How many Games you wish to type in ?) int n; cin>>n; for(int i=0; i<n;++) { cout<<"\n\n Podaj nazwe ",, … | |
This came up in another thread. I gave some advice that I'm not longer sure of. Rather than hijacking that thread, I figured I'd start my own. I advised against using the == in that thread. The context was this: [code=cplusplus] string subChoice =""; getline(cin,subChoice); if (subChoice == "100") { … | |
Re: [code=cplusplus] #include <iostream> #include <string> #include <cstdlib> #include <ctime> using namespace std; int main() { int min, max, number = 0; unsigned seed = (unsigned long) (time(NULL)); srand(seed); cout << "Please enter an integer: "; cin >> min; cin.ignore(); cout << "Please enter another integer: "; cin >> max; int … | |
Re: Read post 9. [code=cplusplus] int Convert_Let_to_Num(int number) { char grade = 0; if ((grade == 'a') || (grade == 'A')) { number = 4; } if ((grade == 'b') || (grade == 'B')) { number = 3; } if ((grade == 'c') || (grade == 'C')) { number = 2; … | |
Re: Three threads, same exact question. [url]http://www.daniweb.com/forums/thread116424.html[/url] [url]http://www.daniweb.com/forums/thread116396.html[/url] [url]http://www.daniweb.com/forums/thread116165.html[/url] | |
Re: I think the isalpha, islower, isupper, toupper, and tolower functions from the cctype library will come in handy here: [url]http://www.cplusplus.com/query/search.cgi?q=cctype[/url] Isolate each character, then test that character with the isalpha function to see if it is a letter. If it IS NOT a letter, just display the character. IF it … | |
| |
Re: Four threads, same question: [url]http://www.daniweb.com/forums/thread116166.html[/url] [url]http://www.daniweb.com/forums/thread116394.html[/url] [url]http://www.daniweb.com/forums/thread116401.html[/url] [url]http://www.daniweb.com/forums/thread116409.html[/url] | |
Re: What exactly are you trying to display here? (see red): [code] cout << setw(6) setprecision(0) << fixed << i << setw(18) << setprecision(2) << fixed << [COLOR="Red"]ftC(i)[/COLOR] << setw(17)<< setprecision(0) << fixed << i << setw(18)<< setprecision(2) << fixed << c << endl; [/code] ftC is a void function. If … |
The End.