1,362 Posted Topics

Member Avatar for rose_lod

[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 …

Member Avatar for BevoX
0
89
Member Avatar for replic

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.

Member Avatar for replic
0
238
Member Avatar for zacknie

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.

Member Avatar for zacknie
0
140
Member Avatar for txman

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( …

Member Avatar for vmanes
0
95
Member Avatar for Brandon515

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 …

Member Avatar for siddhant3s
0
100
Member Avatar for nick2price
Member Avatar for orwell84

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 …

Member Avatar for siddhant3s
0
127
Member Avatar for mtramnes

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 …

Member Avatar for vmanes
0
118
Member Avatar for bhavya_talluri

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 …

Member Avatar for siddhant3s
0
413
Member Avatar for The Dude

[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.

Member Avatar for Robdale
0
53
Member Avatar for arpitha_ks

[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 …

Member Avatar for siddhant3s
0
87
Member Avatar for Tyrick

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 >> …

Member Avatar for vmanes
0
86
Member Avatar for jamboadams

[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 …

Member Avatar for vmanes
0
1K
Member Avatar for greg022549

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; …

Member Avatar for vmanes
0
90
Member Avatar for urbandad70

[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, …

Member Avatar for jencas
0
142
Member Avatar for jdm
Member Avatar for darked90

[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. …

Member Avatar for darked90
1
327
Member Avatar for thingstealer
Member Avatar for yang120

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 …

Member Avatar for yang120
0
154
Member Avatar for qajaq49

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] …

Member Avatar for qajaq49
0
12K
Member Avatar for Yaserk88

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; …

Member Avatar for vmanes
0
98
Member Avatar for minime2100

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 …

Member Avatar for minime2100
0
94
Member Avatar for rafkay

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 = …

Member Avatar for vmanes
0
220
Member Avatar for dise652

A hundred gazillion webpages, blogs, and twits on the internet, and not a thing worth watching. (paraphrase of an old saying about TV)

Member Avatar for ahihihi...
-1
118
Member Avatar for vegaseat

[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.

Member Avatar for sneekula
0
148
Member Avatar for daviddoria

How about [code] void CharArray ( unsigned char arr[] ) { arr[0] = R_; arr[1] = G_; arr[2] = B_; } [/code]

Member Avatar for ArkM
0
86
Member Avatar for Manutebecker

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 };

Member Avatar for DemonGal711
0
127
Member Avatar for deepalici0us

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 …

Member Avatar for vmanes
0
267
Member Avatar for raymyster

Another approach might be to convert both the values ABCDE and 4*ABCDE to strings, reverse one of them, and use string comparison.

Member Avatar for vmanes
0
120
Member Avatar for tones1986

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 …

Member Avatar for DemonGal711
0
713
Member Avatar for sarifah
Member Avatar for StandardsDT

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.

Member Avatar for StandardsDT
0
141
Member Avatar for shahab.burki

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( …

Member Avatar for Comatose
0
79
Member Avatar for rudasi

[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 …

Member Avatar for rudasi
0
158
Member Avatar for cassie_sanford

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 …

Member Avatar for vmanes
0
111
Member Avatar for mtramnes

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.

Member Avatar for mtramnes
0
153
Member Avatar for daviddoria

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 …

Member Avatar for vmanes
0
158
Member Avatar for iansane

[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.

Member Avatar for vmanes
0
767
Member Avatar for The Dude

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?

Member Avatar for jbennet
0
45
Member Avatar for fidan

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.

Member Avatar for GDICommander
0
163
Member Avatar for homeryansta

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++; …

Member Avatar for homeryansta
0
129
Member Avatar for Duki

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 …

Member Avatar for Duki
0
103
Member Avatar for xtremerocker

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.

Member Avatar for xtremerocker
0
215
Member Avatar for booker

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.

Member Avatar for vmanes
0
78
Member Avatar for massivefermion

Yes, using VB for the front end and C++ to make dll's that do some of the processing is quite possible.

Member Avatar for vmanes
0
175
Member Avatar for ithelp

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.

Member Avatar for ithelp
0
212
Member Avatar for stephen84s

[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]

Member Avatar for Ezzaral
0
129
Member Avatar for pcongnu

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 …

Member Avatar for galin
0
92
Member Avatar for shasha821110

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]

Member Avatar for soroushc
0
158
Member Avatar for vmanes

[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. ;)

0
64

The End.