1,362 Posted Topics
Re: [QUOTE=codeaa;542092]I'd bet his file is named inData.txt, in his code it's inDatat.txt. You probably named it as in the code.[/QUOTE] Yep, you've probably nailed it. Exo - you should [b]always[/b] test for successful file opening (particularly input files) before using them. As you see, it's quite possible that the [b]attempted[/b] … | |
![]() | Re: zhelih - please go back and fix your OBO error. Or are you trying to give TechBoy a wrong homework answer? |
Re: No, I think it means that the object from which the const function is being called will not be changed. Using your example function (a method of the classA class) [code] classA A; classA B; A.fun( B ); [/code] guarantees that object A will not be changed by the actions … | |
Re: 692 lines - "Holy long code, Batman!" First, stop with the multiple lines of [inlinecode]cout << endl[/inlinecode] for spacing. If you really need the vertical space, output the endlines in a loop. Second, you have duplication of code blocks to handle responses in the upper case and lower case. Combine … | |
Re: And, save yourself and others who read the code a lot of time and confusion by not putting in redundant, uninformative comments: [code=c++] valid = false;// Set the valid input indicator false fin >> dimension;// Get the matrix dimension if (dimension <= 9) {// If the input is good [/code] … | |
Re: You need to look closely at what you're doing in the NextGeneration( ) function. You pass in nextgen array, but don't use it to calculate the changes. Then you go and copy the blank nextgen array over the original. Be consistent in writing 0 or 1 to the arrays, not … | |
Re: In your call to the DetQueen( ) function, you must pass the array (actually, the starting address of the array.) You are in fact passing it a single element, an int, when you put two index values after the array name in your call. [code=c++] int main() { int chessboard[8][8]; … | |
Re: In the simple case of a few functions, maybe class definition, and you don't mind it being compiled with every new program you use this collection, simply saving the file as a .h (or even a .cpp) file and and using [inlinecode]#include "myfile.h"[/inlinecode] add it to the current project. A … | |
Re: [QUOTE=VernonDozier;538633] since C++ wouldn't know how to compare a and b. But this would work (after you wrote function lessThan): [code] csv a, b; // code if (lessThan (a, b)) { //code } [/code][/QUOTE] or, simply compare the relevant members directly [code] if( a.numeric_member_n < b.numeric_member_n ) [/code] Remember that … | |
Re: function main( ) ends at line 77. The code beginning at line 83 is just out there in space. Is it supposed to be another function? If so, it needs a header. | |
Re: How about [inlinecode]for (b = 1; b <= a; b++)[/inlinecode]? | |
Re: You could examine the string character by character, using the isupper( ) function from library <cctype>. When you find one, return that index. Or, make use of the string function find_first_of( ) as this sample shows [code] #include <iostream> #include<string> using namespace std; int main() { string s = "heLlo, … | |
Re: Every time you open the output file, by default it gets truncated (content deleted.) As Duoas said, there's no need to repeatedly open and close it. Your computer will waste more time just doing that than actually doing the work of the program. | |
Re: Firstly, please indent code for readability, and use the code tags (see the Announcement about BB tags) You write the conversion functions, but never use them. You need to put curly braces { } around the code that makes up each if block. You cannot put the calculation for temp … | |
Re: Also, your logic for checking valid day of month will fail to do its job [code] if ( (month==1 || month ==3 || month == 5 || month == 7 || month== 8 || month== 10 || month==12) && (day >= 1 || day<=31) && (year>=1860 ) ) [/code] Look … | |
Re: I think that before you try doing screen graphics, you should go back to square one on writing C++ code. What you have stands no chance of compiling, much less doing what you think you want it to do. Just looking at your very first function [code=c++] int random_x_unit(x) { … | |
Re: Perhaps a little more explanation of the problem. What sort of data? How must it be accessed, sorted, filtered, etc? How much data? This is a C++ forum, do you intend to write the code? | |
Re: As a teacher, I'd take it to mean VernonDozier's first sample above. | |
![]() | Re: VC++ Express 2008 includes the SDK when installed, unlike the 2005 version. Are you trying to create a Windows app, or a console (DOS box) app? |
Re: Comments: What kind of calculator gives result to just one decimal place? Why would you use it? Why would you want to throw away precision? Most of us strive to maintain as much precision as possible for as long as possible in any chain of expressions. Let rounding occur on … | |
Re: I think the ios::app is absolutely necessary in the output option, otherwise every new circle will overwrite the previous data (default file open mode is ios::trunc). ios::app has no meaning to an input file action, as AD said. In the search section, you ask user for circle ID. Then you … | |
Re: Your tests and adjustments for month rollover should be inside the month group if's, not as separate else if's. You testing for day ranges should be day >=1, not strictly >1 (what happens when you try to advance from first of a month?) Do you really need to test day … | |
Re: I think the input programwould be cleaner as: [code=c++] /* Name- inp_arr parameters- none output - none ()*/ #include<iostream.h> #include<conio.h> int main () //note this must by "main" to be a valid program { int a[100]= { 0 } , i = 0; int input; cout<<"Enter the integer array and … | |
Re: [QUOTE=silverowl;529933]Ummm...I've a CAT on my desk:D My kitten likes to sleep here, near the monitor and me :D Bet not many have that :D[/QUOTE] Until we swapped out our 19" CRTs for LCD displays, wife and I both often had cats sleeping on the monitors. Nice and warm. One of … | |
Re: What do you see as the problem? Does it compile? If not, what error messages do you get, where do they point you? Can you fix them? If it does compile, what behavior do you see when you run it? How does that compare to the behavior you expect to … | |
Re: Did this actually compile for you? If so, what results does it give? It looks like you're doing too much spinning in the loop to find the match to characters, but it works, I think. What is the code at lines 42-44 below supposed to be doing? Comparing strings to … | |
Re: You have a variable "pow" which is masking the function pow( ). You don't use that variable, so remove it. Also, in your red line, why are you doing [inlinecode] cin >> num2 * ......[/inlinecode]? Don't you really want to be doing output? | |
Re: [QUOTE=jwenting;530846] <snip> It's not as if they need it. A decent school library should contain whatever they require to get their studies completed.[/QUOTE] Have you seen the amount of funding that libraries <don't> get these days? We've insufficient funds to get even a handful of the journals students (and faculty … | |
Re: You need to clarify the problem a bit. Is it your intent to overwrite the original plaintext in the file with the encrypted text? In that case, you'll have to open the file as an "fstream" with both in and out modes. You will have to keep track of where … | |
Re: Have to? Never. I have done reinstalls maybe twice in 15 years by choice. One Win98 box went 5 years or so, was just getting all full of leftovers. Same for an XP box after 4 years or so. Neither was strictly necessary. My boxes tend to just keep on … | |
Re: Your problem statement is not very clear. In what form is the time entered by the user? Total seconds, 24-hour time, StarDate? How does division by 10,000 come into play? | |
Re: Dreyer's Fudge Tracks - No Sugar Added. And I like McDonalds soft serve - it's sooo smooth and creamy. | |
Re: Short of examining the object code created, probably no definitive answer. It may be compiler dependent. In a brute force approach, run the two operations in a verrrrry big loop, time the differences. I just tried this: [code] #include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main() { … | |
Re: [QUOTE=MKQ;524918] "The power of face to face communication is more effective than the other mode of communication ?" [/QUOTE] Which "other mode"? Face to rear, face to feet, rear to rear? :-/ Really, the mode that's most effective depends on the situation, the kind of communication and desired results. Detailed … | |
Re: The whole idea of private data members is to prevent code outside the class from directly accessing them. Two reasons: 1. To hide the actual method of storing. Does it matter to main.cpp whether you use a char array based string or a string class item to hold the names? … | |
Re: Home Premium on my personal laptop. Business at work (running in a VM on an XP Pro machine) | |
Re: The error is caused by your naming a variable the same as the function [code=c++] case 3: int removeAll; //this variable masks the function call that follows cout << "Please enter number to remove multiple occurences." << endl; cin >> removeAll; removeAll(intArray, sizeOfArray, removeAll); break; [/code] Looking at the removeAll( … | |
It was good knowing you. [URL="http://www.csmonitor.com/2008/0131/p25s01-stct.html"]Netscape, 1994-2008[/URL] | |
Re: [QUOTE=sneekula;522574]Blogging is one way to spread the truth and the news. I am all for it! Yeah Bloggers![/QUOTE] But most bloggers have no accountability, responsibility, or just plain ability. 99% of what's on the internet is noise. And blogs have made a big contribution to that noise level. Then there's … | |
Re: I think you need to clarify what the problem is. What are you supposed to do n times to (array?) indexes 1-n? Read more data from file? Generate random numbers? What does divisibility by 3 or by 5 have to do with using setfill? Be sure you understand the problem, … | |
Re: In a related stream, there's an older one where a deer attacks hunter: [url]http://origin.www.spike.com/video/2718572[/url] | |
Re: your program is working correctly, and is doing [b]exactly[/b] what you told it to. The second line of text is written to the file, as you'd see if you opened the file in an editor. Here's what's confusing you: [code] myfile.getline(buffer,300); [/code] Remember that getline reads into buffer, up to … | |
Re: 1) Assuming that "figure" is a character, the input statement only takes the first non-whitespace character from the input stream. So, in your example, the '2' is left to be processed, and it then becomes the first input to whichever figure is being calculated. One way to handle this is … | |
Re: When you read the file completely through the first time, the EOF flag was set in the object fin. That flag stays set until you use the fin.clear( ) statement. The act of closing, or reopening, the file does not clear the flag. This does not really have anything to … | |
Re: With such a large file, it would be helpful to have line numbers to find where the error message is pointing. When posting code like this, use the form [noparse] [code=c++] void lfib(int a){ int i; } [/code] [/noparse] which will make your code look like: [code=c++] void lfib(int a){ … | |
Re: [quote]Programmers are in a race with the Universe to create bigger and better idiot-proof programs. The Universe is trying to create bigger and better idiots. So far the Universe is winning. --Anon [/quote] This is often attributed to Rick (Rich) Cook, author. (I've got one or two of his books, … | |
Re: Size of integer types is dependent on the architecture being supported: [QUOTE] There are four signed integer types: “signed char”, “short int”, “int”, and “long int.” In this list, each type provides at least as much storage as those preceding it in the list. Plain ints have the natural size … | |
Re: Not knowing anything about your eArray class, it's hard to give you any help. More info would improve the chances of your getting some advice. | |
Re: [QUOTE=GrimJack;515949]Hey, if you decide to go the laser surgery route, try and get an ex-USAF doc - Pilots need near-perfect vision uncorrected so the AirForce docs do thousands of these operations with near 5 nines success rates. In fact, they are so successful that there is a decided lack of … | |
Re: I love the smell of napalm in the morning. You know, one time we had a hill bombed, for 12 hours. When it was all over, I walked up. We didn't find one of 'em, not one stinkin' dink body. The smell, you know that gasoline smell, the whole hill. … |
The End.