1,362 Posted Topics
Re: [quote]but it seems that i'm missing something[/quote] Umm, like maybe the code? My crystal ball is out for a tuneup right now. Please post your code, or pertinent portion of it, and try to describe what particular problem you're having. No one here is going to write the program for … | |
Re: also use mode std::ios::ate (AT End) The default mode for ofstream opening is std::ios::trunc, (TRUNCate), which deletes any previous content of the file. ios::ate preserves the file, allows you to move the file pointer anywhere within the current content. | |
Re: As you get the input from user, you never update the quantity array. And, that array should be set to all zeros when you declare it, otherwise you would be incrementing starting at random values. | |
Re: If you paid attention to the error message generated by this code, you'd have an idea that the ofstream cannot take a string type as the filename parameter. You must use a C-style, character array based, null terminated string for filenames. But, there's a way out. Look up the c_str( … | |
Re: First program? Really? Function main( ) does not need a prototype. Function haha( ) is quite clever, sort of. It's really a bit confusing to be calling this to keep the program looping through the options. What's going on is a growing pile of functions on the stack - like … | |
| |
Re: Get rid of all the cin.get( ) statements. Your loop will give a multitude out outputs for any test value. You need logic that will halt when input number is shown to be non-prime, or let the loop go the whole way, keeping track if non-primeness has been detected. At … | |
Re: An additional note on what to set min/max to at the start - set them both the first data value in the set. That way, you don't have to be concerned with what range the data may be, and you will always have a correct answer as you compare min/max … | |
Re: I think that's telling you you're using outdated library names. Your #include's should be [code] #include<iostream> #include<cstdio> #include<conio.h> #include<cmath> [/code] Also, in the future, please post your code between code tags, like: [noparse][code] your code goes here [/code][/noparse] That goes a long way towards making it more readable. Once you … | |
Re: [QUOTE=The Dude;810447][url]http://www.zuzafun.com/sand-art[/url] [url]http://dude111.fileave.com/2.htm[/url] I couldnt believe what i was l00king at!! How do they make them SO BIG??[/QUOTE] It's a trick with the telephoto lens! Ok, really - right kind of sand, proper application of water. And Practice, Practice, Practice. | |
Re: [quote]but it is giving error like " a constant expression is required "[/quote] Current C++ standard requires that an array declaration as you're trying must use constant values for the dimension sizes. Either literal values [icode] int array[10][20][/icode] or some other type of contant (non-changeable) value, like [code] const int … | |
Re: You can use ctrl-z (ctrl-d in *nix systems) to signal end of input - it works the same as running out of data when reading a file. You might have something like [code] int arr[100] = { 0 }; int i = 0; while( i < 100 && cin >> … | |
Re: [QUOTE=jamboadams;94696]well the project is for a intro level c++ class , so it seems like the prof wouldnt require us to do soemthin that required libraries other than the ones in code warrior to start with. im thinkin im gonna have to store the value as a character array and … | |
Re: Let's just take one little bit and find some problems for you to fix [code] if((clientMembership=="Bronze \n")||(clientMembership=="bronze \n")); cout<<"Client has Bronze therefore 15% discount off Total Price\n"; if((clientDestination=="Japan \n")||(clientDestination=="japan \n")); clientDiscount = .85; clientTotalPrice = 7113; result = clientTotalPrice * clientDiscount; cout<<" The price is a total of : "<<result<<endl; … | |
Re: [code]inputARRAY[row][col];[/code] Does not do anything. Nothing. Nada. So, you never get to end of file, and thus your loop runs forever, or until you pull the plug, whichever comes first. Please refer back to your lesson on how to read from a file. And if this is the same problem, … ![]() | |
Re: [code] if(send = true) //if statement to print if the user passed or failed cout <<"You have passed the exam!\n"; else if (send = false) cout <<"You have failed the exam.\n"; [/code] As I mentioned to the other poster of similar code, you've made a small, common mistake in here. … | |
Re: Works fine for me in Visual C++ 2005. | |
Re: Couple of things- please read the sticky threads at the top on good posting procedure. Mainly, please put your code inside code tags, like: [noparse][code] your code goes here [/code][/noparse] Then, please ask a full question. What do you mean by "my first part" and "is not right"? What error … | |
Re: AcctNum[0] is a character (type char). 'b' is a character. "b" is a string, consisting of the character 'b' and the character '\0' (NULL terminator.) The string is considered a char *, or constant char * in terms of a literal string. The error message, in referring to your AcctNum[0] … | |
Re: Please use the code tags, like [noparse][code] your code goes here [/code][/noparse] This will make your code more readable, assuming you had proper indentation to begin with. What you posted should look like: [code] for (int s=0; s<200; s++) { for (int i=0; i<N_plates; i++) { for (int j=0; j<3; … | |
Re: Several points. 1 - strings - you're setting up C-style, char array based string, but not using the string functions for any manipulations. Look up this topic, especially strcpy( ). 2. Your constructor is allocating (again) a string and double - all it should do is set intitial values to … | |
Re: In order to sort the data read in from the file, you'll need to store it into an array, which you then pass to your sort function. Just a little fixing to your code: [code] ifstream OpenFile("D:\\dataM.txt"); int a[1000]; //make this big enough to hold the data int i = … | |
Re: A hundred gazillion webpages, blogs, and twits on the internet, and not a thing worth watching. (paraphrase of an old saying about TV) | |
Re: [QUOTE=Ezzaral;803017]Yeah, I always thought that Tom Hanks guy was kind of shifty...[/QUOTE] Unless they've really, really messed up the story, Hanks's character is the good guy, trying to prevent the Vatican from being blown up. | |
Re: How about [code] void CharArray ( unsigned char arr[] ) { arr[0] = R_; arr[1] = G_; arr[2] = B_; } [/code] | |
Re: Don't define class Card within class Deck. Create a card class. Then let deck class contain an array of card objects class Card { string suit; int value; ///more stuff }; class Deck{ Card theDeck[52]; //more stuff }; | |
Re: You will have just one text file, containing information on multiple students. Your data in the program should be stored in an array of the StuRecord objects. I would store the three grades in the StuRecord as an array, rather than three separate variables. Not that it's crucial here, but … | |
Re: Another approach might be to convert both the values ABCDE and 4*ABCDE to strings, reverse one of them, and use string comparison. | |
Re: Your searching is not actually returning the found object (actually, I don't think it's finding anything, it's hitting on the first node - that's another problem) To get info back, try these changes: [code] CourseInfo Student::checkCourseTaken(string ZID, CourseInfo c1) { CourseInfo c2; c2 = courseList.checkCourseTaken(c1)->info; return c2; } // public … | |
Re: While you're at it, don't forget /= and %= | |
Re: Your do...while loop never ends, because endingcoupon is always 1. You need to reexamine what your process is - I can't really follow what you're trying to do. If you redeem coupons, something has to be reduced so that further looping starts from a lower value. | |
Re: Yes, when you might want to aggregate multiple data members. This is rather trivial example, but illustrates how it might be done. [code] #include <iostream> using namespace std; class foo { public: foo( ); void display( ); private: struct pt { int x; int y; }; pt point; }; foo::foo( … | |
Re: [QUOTE=rudasi;803818]Thanks, i forgot about that :) .It gets truncated. Thanks once again.[/QUOTE] Just to clarify (words mean things) What you've got is the result of integer division. Truncation is what happens when you assign a floating point value that has a fractional part to an integer variable, or typecast the … | |
Re: It's not showing up above - is it that you want the numbers all aligned at the decimal, like [code] 123.56 56.66 3.99 [/code] If so, you need to put the setw(12) after the $ output. If you want the $ right up against the numbers, which are decimal point … | |
Re: You need curly brackets around the two statements that follow the for loop so that both the increment and the display occur. Start count at 0. | |
Re: A recursive function needs a base case - something that will cause it to stop recursing. That said, your general idea of storing the MaxDistance in the reference parameter will work - all attempts to compare to/store to the variable will be access the same memory object, no mater the … | |
Re: [QUOTE=smithss;800872]Hey, output: 12.53 16.52 How is it possible that setprecision is rouding 12.525 to 12.53 but 16.525 to 16.52 :-O !!![/QUOTE] If you display the values with a large precision, you'll see that what's actually stored is: 12.52500000000000000000 16.52499999999999900000 That explains your second value being rounded down. | |
Re: I might have submitted for a sample, but a site that asks for personal info and has no privacy policy statement available (nor any real info on the company, for that matter) will not get my input. Really, vodka that's been filtered over diamonds? What's that gonna do? | |
Re: Since the program works for many CNF files (what are they, by the way?) - can you find anything different about the problematic data? Is it significantly longer? Could you have a buffer overflow? More info gets better responses. | |
Re: You're OK till the while loop - what's it supposed to be doing? How about something like: [code] if( inputfile ) //file opened, let's do some work { while ( inputfile >> temp ) //gets one word at a time { //if successful, store the word list.insert( temp ); i++; … | |
Re: Assignments can/should only be made between equivalent types. Follow the paths, there are some errors in there. Can you assign the info member to a ptr? What to the couple of dereferencing actions do? Pointer usage is one those areas where C/C++ give you lots of rope to shoot yourself … | |
Re: I'm curious as the purpose of this. You're ending up with values on the order of 2^30,000 - that's so incredibly huge I can't even fathom it. I get dizzy on long long int - 2^64. | |
Re: When you call the function a second time, without having reset the filestream you pass to it, your filestream is in a bad state. You read it to its end in the first iteration of the function, so there's nothing more you can do with it. | |
Re: Yes, using VB for the front end and C++ to make dll's that do some of the processing is quite possible. | |
Re: Cost of printing a $100 bill? About the same as a $1 bill. From this [URL="http://www.federalreserve.gov/generalinfo/foia/2007newcurrency.htm"]2007 information[/URL], it looks like about 5.5-6.5 cents per bill. | |
Re: [URL="http://research.microsoft.com/en-us/um/redmond/projects/songsmith/about.html"]Here's [/URL]what will be the death of M$ Evil Empire. Or [URL="http://www.pcmag.com/article2/0,2817,2339520,00.asp"]this[/URL] | |
Re: You are outputting the full array. Your output routine should stop when it encounter the NULL terminator of the fourth string. Rather than loop through the array, why not just [icode] cout << f; [/icode] Going further, your assignment says to use separate arrays for each input string. You have … | |
Re: Good guess, but not quite solving the problem Both of your loops will keep you entering numbers forever [code] while( cin >> val ) { if( cin.fail( ) ) { //do nothing, we've reached the quit criteria } else { //do the summation and counter increment } } [/code] | |
[URL="http://www.freakybestmanspeech.com/"]Freaky Wedding Toast[/URL] You must watch all the way to the end. Not responsible for what you may spit up on your keyboard. ;) |
The End.