537 Posted Topics

Member Avatar for seion

[b]calculator:[/b] pretty descent. since i have a different coding style i would have done some minor things different, such as instead of using an infinite [icode]while(true)[/icode] loop, i would have done [icode]while(toupper(answer) != 'Q')[/icode] to avoid having to [icode]break;[/icode] out of a loop. also, i tend to stay away from …

Member Avatar for Clinton Portis
0
154
Member Avatar for crystalll

Firstly, you seem to have a cool chick name; therefore, I will have to ask ye' a/s/l. Secondly, (without having to look at your code) tie detection in tic-tac-toe can be as simple as testing a turn counter... when a player has reached 5 turns, and none of ye' win …

Member Avatar for Schol-R-LEA
0
609
Member Avatar for Awais Ali

Pamela Anderson is one example of a pseudo stack. Others include Heidi Montag, Salma Hayek, Nichole Ritchie, Christina Aguilera and Dollie Parton.

Member Avatar for Awais Ali
0
217
Member Avatar for Jdan2388

[quote] but my problem now is that when i try to pass the arrays to the calculate data function its not passing the array and for some reason in they yards array its passing 2750 which is the last number in the yards array. [/quote] if it's not too much …

Member Avatar for Clinton Portis
0
140
Member Avatar for MachDelta

you need to make sure your header and function definitions are added to your project.. in dev c++ they will appear in the project window on the left side.

Member Avatar for Schol-R-LEA
0
130
Member Avatar for learner guy

Whether it be making ascii to int conversions, or splitting up a string into tokens, probably the best method to use is <stringstream>. Here is a small [URL="http://www.cplusplus.com/reference/iostream/stringstream/stringstream/"]example[/URL]: [CODE]// using stringstream constructors. #include <iostream> #include <sstream> using namespace std; int main () { int val = 0; stringstream ss; ss …

Member Avatar for learner guy
0
202
Member Avatar for imsinu

ye' could chain the cin operation together like this: [code] cout << "Enter clock time: (HH MM SS) "; cin >> hour >> min >> sec; [/code] of course this method is highly dependant on the user making proper input seperated with white spaces.

Member Avatar for imsinu
0
198
Member Avatar for smallrubberfeet

I think what you want to do is to load a text file into a single linked-list data structure, and then offer the user to sort the list by certain attributes; in the case you speak of, by user i.d. So let's break this mother down step by step. Let's …

Member Avatar for Clinton Portis
0
2K
Member Avatar for thenewbiecoder

[quote] 1. There are functions to Add, Subtract, Divide, Multiply the fractions. 2. There are two other functions to return the numerator and denominator. 3. Finally, an overloaded operator should be able to compare whether two fraction objects are greater than, less than, or equal to one another.[/quote] Although I …

Member Avatar for vijayan121
0
3K
Member Avatar for dannyc116

Line #31: the [URL="http://www.cplusplus.com/reference/string/string/"]string class [/URL]does not offer an overloaded ==, it only offers overloaded = assignment, += accumulation (append), and [] array subscript and of course an overloaded () operator as a constructor. But what the string class does have that ye' can use instead of a == is …

Member Avatar for Clinton Portis
0
7K
Member Avatar for eblanco1
Member Avatar for izh

this isn't that difficult.. it's pretty straight-forward file i/o. which concept is giving you trouble?

Member Avatar for izh
0
248
Member Avatar for Vonga

A brief translation from C to C++... [code] #include <iostream> #include <cstdlib> #include <time> void bubble_sort(int n, int z[]) { int i=0, j=0, x=0, k=0; for (i=2; i<=n; i++) { for (j=n; j>=i; j--) { if (z[j-1] > z[j]) { x = z[j-1]; z[j-1] = z[j]; z[j] = x; } …

Member Avatar for Vonga
0
136
Member Avatar for pato wlmc

I believe that 'i' is used in accordance with the rules of Hungarian Notion; a coding style used to self identify the type variables (int type vars use 'i'). [URL="http://msdn.microsoft.com/en-us/library/windows/desktop/aa378932(v=vs.85).aspx"]Check out Hungarian Notation.[/URL]

Member Avatar for Tumlee
0
5K
Member Avatar for jlake

I think ye' blackjack program should follow this kinda scheme: [code] //Make your cards like this struct card { char suit; int value; } deck[52]; //Use these functions to check the hand bool is_royal_flush(card hand[]); bool is_straight_flush(card hand[]); bool is_4kind(card hand[]); bool is_full_house(card hand[]); bool is_flush(card hand[]); bool is_straight(card hand[]); …

Member Avatar for WaltP
0
207
Member Avatar for efigen

try this. [CODE] #include<cstring> char* y = '\0'; char temp1[100]; char temp2[100]; for (int i=0; i<length-1; i++) { Search(RecordArray,temp1,n,i); Search(RecordArray,temp2,n,i+1); if(strcmp(temp1, temp2)> 0) { y = &RecordArray[i][254]; RecordArray[i][254] = RecordArray[i+1]; RecordArray[i+1][254] = *y; } } [/CODE] strcmp() will only give ye' the results you want if both arguments are of …

Member Avatar for efigen
0
512
Member Avatar for vishwanath.m

anytime you have to insert something somewhere in a vector, other than at the very end, then ye' should not use a vector. consider using queue or deque.

Member Avatar for raptr_dflo
0
177
Member Avatar for sethii
Member Avatar for astrolegacy

[CODE] struct service_plan { int account_number; char service_code; int data_size; } int main() { //create an array of service_plans //start loop //prompt user for account number //prompt user for service code //prompt user for amount of data //ask user if they would like to enter another record //increment an array …

Member Avatar for astrolegacy
0
153
Member Avatar for skylinedrifter
Member Avatar for Clinton Portis
0
182
Member Avatar for Taino
Member Avatar for Clinton Portis
0
159
Member Avatar for Dakot

On your intended last iteration, line #12 will test true; however, line #14 will perform one additional calculation that you probably don't want it to do and will subsequently print the result (line #15.) One solution could be to change your loop to a do/while so the evaluation to continue …

Member Avatar for WaltP
0
183
Member Avatar for Adnan671

[quote] int strcmp ( const char * str1, const char * str2 ); Compare two strings Compares the C string str1 to the C string str2. This function starts comparing the first character of each string. If they are equal to each other, it continues with the following pairs until …

Member Avatar for raptr_dflo
0
3K
Member Avatar for nchy13

whenver ye' mix formatted and unformatted types o' input, ye' are acksin' for trouble. try cin.ignore() after line #5. flush your buffer.

Member Avatar for jmichae3
0
120
Member Avatar for BlackRocker

[quote] the only problem I have is getting the highest average grade. [/quote] [CODE] double get_highest_average_grade(int grades[8][3]); { double averages[8]; //outside loop //inside loop //add 3 elements //divide by 3 //store result in averages[] //Begin Loop //compare current element to next element of the averages[] array //save the highest of …

Member Avatar for BlackRocker
0
204
Member Avatar for Zssffssz

you just can't arbitrarily assign a const char cstring to a buffer. it physically has to be copied element by element. the [URL="http://www.cplusplus.com/reference/clibrary/cstring/"]<cstring>[/URL] library has everything you need to make cstring assignments: [code] #include <cstring> char* lock = new char[501]; char ret[501] = "this is a fine program"; strcpy(lock, ret); …

Member Avatar for Zssffssz
0
540
Member Avatar for da10x

ye problem is right here: [CODE]if(x = i)[/CODE] you seem to be an intelligent individual. take this opportunity to fix ye' error.

Member Avatar for da10x
0
131
Member Avatar for JNicoleKMC5

If you want a strictly c++ approach, you could create a master .txt file of all the file paths for all your files. This will allow you to load and search through all ye' existing files. [code] ////master.txt //a list of all your existing text files aaron_rogers.txt brett_favre.txt calvin_johnson.txt jahvid_best.txt …

Member Avatar for vijayan121
0
170
Member Avatar for thenewbiecoder

[code] #include<windows.h> #include<iostream> #include<cctype> #include<cstdlib> #include<ctime> using namespace std; class Roulette { public: Roulette(); void board_display(); void prompt(); void bet_menu(); void place_bet(); void set_bet(int choice); void set_bet(int menu_choice, int number, int amount); void set_chip(int); void set_chip(int, int); void spin_the_wheel(); void win_or_lose(); void reset(); bool quit(); void gotoxy(int x, int y); …

Member Avatar for Clinton Portis
0
380
Member Avatar for cafegeo

[quote]I am having a tough time figuring out how to first approach this without confusing myself.[/quote] 1. create an ifstream object 2. open your master file. 3. check for errors. 4. load ye' master file into a [URL="http://www.cplusplus.com/reference/stl/vector/"]vector< >[/URL] of structs. 5. close the ifstream object 6. create another ifstream …

Member Avatar for cafegeo
0
269
Member Avatar for C++newbie chick

Hola chica de newbiliciousness after briefly lookin' at ye' code, try this: [CODE] //instead of }while(choice != 'N'); //try }while(choice != 'n' || choice != 'N'); //and }while(choice != 'z' || choice != 'Z'); //cool alternatives }while(toupper(choice) != 'N'); //or }while(tolower(choice) != 'z'); [/CODE]

Member Avatar for Ancient Dragon
0
317
Member Avatar for ishaan3731

I've read your post, and looked over 395 lines of code, but I still don't know what your problem is. What part doesn't work? What topics are ye' having trouble with? What are your homework requirements? What line(s) of code do you have questions about? What errors and warning is …

Member Avatar for ishaan3731
0
361
Member Avatar for yurigagarin
Member Avatar for Cainer

I've dabbled in winsock a bit. So i'll throw in me' two cents: I believe you should have a couple of struct attributes that include the 'type' of struct, and perhaps also the 'size' of the struct. These should probably be the first two things ye' test for as a …

Member Avatar for Cainer
0
563
Member Avatar for dakerao

[CODE] ifstream infile; string line_of_text; int pos = 0; vector<string> txt_files; vector<string> png_files; vector<string> doc_files; vector<string> bmp_files; infile.open("directorycontents.txt"); if(!infile.is_open()) { cout << "\aError opening file!"; cout << "\nFile may have been deleted, moved, or renamed."; exit(EXIT_FAILURE); } while(infile) { getline(infile, line_of_text); if(line_of_text.find(".txt")) { txt_files.push_back(line_of_text); } if(line_of_text.find(".png")) { png_files.push_back(line_of_text); } if(line_of_text.find(".doc")) …

Member Avatar for WaltP
0
193
Member Avatar for salah_saleh

try this: [CODE] int row = 0; float data = 0.00; vector<vector<float> > initMatrix(5, vector<float>(cols)); while(myfile) { // --Handle 1D element allocation-- //Resize every 5 loop iterations (why not? it's more efficient than re-sizing every time) //This is make sure you have a 1D element allocated in which to 'push_back()' …

Member Avatar for salah_saleh
0
6K
Member Avatar for james6754

Look up any tutorial on the c++ concept of 'dynamic arrays' [CODE] int* myArray = new int[n]; [/CODE]

Member Avatar for james6754
0
88
Member Avatar for stevo7624
Member Avatar for HASHMI007
Member Avatar for Panathinaikos22
Member Avatar for Oscariuz

[quote]Im trying to verify predetermined char in random array so i can know if some of the three char appear three times or more.[/quote] i would probably write a function that will return the number of occurances the desired char appears in your array. then you can test for this …

Member Avatar for mrnutty
0
210
Member Avatar for master dogs

[CODE] while(product <= 1000) { product = result * multiplier; result = product; } [/CODE]

Member Avatar for Clinton Portis
0
160
Member Avatar for eternalblizzard
Member Avatar for eternalblizzard
1
168
Member Avatar for lbgladson

i'll do one for you just to get ye' started: [CODE] //using pointer arithmetic int string_length_1(char* cstring) { int size = 0; while(*cstring != NULL) { //increment the pointer cstring++; size++; } return size; } //Same function using array subscripts int string_length_2(char cstring[]) { int index = 0; //using array …

Member Avatar for WaltP
0
137
Member Avatar for Uranium

is it safe to assume that what you can run on a computer will also run on your uncle's billboard

Member Avatar for Clinton Portis
0
88
Member Avatar for aboyslim

[code] //initialize a 2D array char board[5][9]; //make everything '0' for(int i=0; i<5; i++) for(int j=0; j<9; j++) { board[i][j] = '0'; } //prompt user for number of random steps to take from middle //call a recursive function to populate the board with a random steps void random_step_generator(int& turns, char& …

Member Avatar for Clinton Portis
0
111
Member Avatar for minghags
Member Avatar for speak1

Your general program outline will probably look something similar to this: [code] #include<iostream> using namespace std; //Function prototypes int prompt(); double calculate_commission(double& commission); //main driver int main() { //local function variable declaration(s) double commission = 0.0; //main loop while(prompt()) { calculate_commission(commission); } return 0; } //Function Definitions int prompt() { …

Member Avatar for Zssffssz
0
465
Member Avatar for valestrom

it can go as high as you need it to go. there is no limitation. even if hardware limitations are exceeded, ye' can still use a net based resource, which is limitless.

Member Avatar for Clinton Portis
0
262
Member Avatar for Mr. K

in line #21, are you reading in 'maxlines' every loop iteration? is this necessary? also, lines #22 and #23 you are re-allocating memory for 'element' and 'symbol' each loop iteration. Instead, try allocating the memory once, when the variable is declared. Then, every time you make a read operation, store …

Member Avatar for Mr. K
0
211

The End.