537 Posted Topics
Re: Looks like you got a lot of the file I/O handled.. i'll just give ye' a little psuedo to get you on your way: [CODE] //Load your files into int[20] arrays for(int i=0; i<20; i++) { file1 >> array_one[i]; file2 >> array_two[i]; } //Multiply each array, element-by-element and save results … | |
Re: this is a c++ forum. this is not a c forum. | |
![]() | Re: ye' need to enclose your if() case in curly braces; [code] if(something) { //do stuff } else if(something) { //do other stuff } else { //do something else } [/code] simple mistake. |
Re: Here is the pseudo for what ye' are wanting to do: 1. open the text file 2. perform error handling; check if file open was successful. if unsuccessful, handle accordingly. //Begin Loop// 3. using a loop, push each word into a temp_string. 4. pass the temp_string into a function that … | |
Re: [quote]how can I read specific data from file?[/quote] I have designed my own method which involves stepping through each character of a text file once and recording the position of all the new lines, but I think someone else might have a more efficient method. Or.. you can just push … | |
Re: [code] cout << "How many seconds did ye' object fall? "; cin >> seconds; for(int i=0; i<seconds; i++) { distance += .5 * g * pow(t, 2); } cout << "\nTotal distance traveled: " << distance;[/code] This is enough to get you thinkin'. There are some obvious unanswered questions here, … | |
Re: please, dont be shy. tell us what ye' problem be. | |
Re: I'm glad you asked, because when I was a beginning programmer back in CSC100, I wondered the exact same thing. If your school offers a course in assembly language, it will definitely unlock this mystery, as a lot of operations at the assembly level use bitwise operations. Here are just … | |
Re: Ye' never state what ye' problems is, but i'll guess it has something to do with float precision. there are a couple o' ways to set precision: [code] cout << setprecision(2); // or cout.setf(ios::fixed); cout.setf(ios::showbase); cout.precision(2); [/code] | |
Re: Arrr matey, the error of ye' ways be in lines #35 & #37. Yarrrr. | |
Re: try this: [code] #include <windows.h> //Declare a 'handle' type object HANDLE console_handle; //Get the 'handle' of the console window console_handle = GetStdHandle(STD_OUTPUT_HANDLE); //Change the title bar text SetWindowText(console_handle, "I want to be the very best.");[/code] [URL="http://msdn.microsoft.com/en-us/library/windows/desktop/ms633546(v=vs.85).aspx"]Here[/URL] is a reference for the SetWindowText() function. [URL="http://www.adrianxw.dk/SoftwareSite/index.html"]Here[/URL] is a reference for using basic … | |
Re: in my opinion, you should write your own function specific for testing cases where input is strictly 'all consonants', and handle this case accordingly. just because your teacher didn't put this in your assignment doesn't mean ye' shouldn't take the initiative. | |
Re: Ye' have the useMoney() function prototyped to accept a float deposit and a float withdrawal. Both of these variables you have declared inside the main() function on line #60; however, ye' did not pass these vars into the function. [u]Solution[/u]: change line #70 to accept your balance and withdrawal vars … | |
Re: [quote] the thing giving me trouble at the moment is how to read and store a floating point number within a struct, the data specifically for the mark is on 1 line of a text file seperated by white space.[/quote] Since ye' data is white space delimited, ye' can simply … | |
Re: String is a class object. It contains it's own member variables and functions. Some common (and very handy) string class include (but not limited to) size(), length(), empty(), clear(), compare() and c_str(). String class objects also have overloaded operators, such as [], (), += and = . Cstrings, or 'character … | |
Re: So what are ye' trying to do with this code? (why doesn't it work the way you think it should) | |
![]() | Re: one recommendation i would make.. you have several lines of beep(900,100). i would advise creating two int's that will hold these values. for example: [code] //instead of beep(900,200); //try int frequency = 900; int duration = 200; beep(frequency, duration); [/code] that way after you got your program up and running.. … |
Re: if pseudorandom21 is correct, perhaps having random access to the file data would be an alternative to having to read in the entire file at once. | |
Re: perhaps computer programming isn't the field for you. perhaps you should change your major to liberal arts or something. | |
Re: learning c++ in 24 hours would be like trying to learn women in 24 hours. | |
Re: [quote] Write a C program... [/quote] I don't go to a java website asking for c++ help. Why do you come to a c++ forum asking for C help. I just don't understand why this is such a common occurance. | |
Re: I believe <fstream.h> is either non-standard or an antiquated header for c++ (i think it's a C header); in which case, would make your instructor incorrect. Sometimes the real education occurs when you have to prove your instructor wrong. According to wikipedia, the use of ".h" header files is depreciated: … | |
Re: I've never actually used the stdafx.h pre-compiled header personally; however, i did a [URL="http://en.wikipedia.org/wiki/Precompiled_header"]wikipedia search[/URL] for this header and found some information: [quote] Common Implementations stdafx.h stdafx.h is a file, generated by Microsoft Visual Studio IDE wizards, that describes both standard system and project specific include files that are used … | |
Re: Ya'll should run straight to youtube for your tutorial needs... so many to chose from, but here is what i think is a good one based on a couple minutes of sifting through them: [url]http://www.youtube.com/watch?v=j3ZR_EpzlSU&feature=related[/url] One major difference between linked lists and any other data structure you've used thus far, … | |
Re: Depends on ye' operating system. If windows OS, you can use the <windows.h> library to populate attributes of the Win32_DiskDrive Class: [url]http://msdn.microsoft.com/en-us/library/aa394132%28v=VS.85%29.aspx[/url] I believe the specific attribute ye' are looking for is [b]string SerialNumber; [/b] [quote] SerialNumber Data type: string Access type: Read-only Number allocated by the manufacturer to identify … | |
Re: Incearca sa schimbe linia #39 din || la && | |
Re: [quote] I'm very new to C# [/quote] Do you think asking for homework help in a c++ forum will further your efforts in learning c pound? [LIST=1] [*]Accept input from user. [*]Store input from user in a container of your choice (probably an int array) [*]Using a loop, step through … | |
Re: since you have varying possibilities of user input, i believe the better approach to this problem would be to read in the entire chunk of user input, test the input, and parse into individual substrings as desired. Here is one possible method using the versitle <sstream> library (very useful for … | |
Re: in my opinion, data hiding in today's IT can be best utilized in a few specialized scenarios: if working on a classified/sensitive project, tasks can be delegated to specific departments, and assembled by one specific person/department. this ensures a 'balance of power' and a system of checks and balances among … | |
Re: Your code here is fine. The problem must be occuring somewhere else. | |
Re: Try this: [code] char letter = 32; int counter = 0; while (letter < 128) { cout << letter << ' '; counter++; if(counter == 16) { cout << endl; counter = 0; } letter++; } [/code] | |
Re: you've done everything for writing to a file, but there is absolutely no code for opening and reading from a file. | |
Re: whenever ye' are using a fstream object multiple times, you should clear the object before using it again. try calling infile.clear() in the beginning of your function and see if that helps. | |
I was just wondering if ya'll knew of any dictionary libraries that I could include in one of my c++ projects. A quick google & forum search have offered solutions in other languages, such as python and c# but have seen nothing specific for c++. Thanks in advance. -d.w. | |
Trying to make a quick little tool in response to the [URL="http://www.msnbc.msn.com/id/42348642/ns/technology_and_science-security/"]FBI's request for assistance[/URL] on cracking a code.. getting an error that takes me outside the scope of my program.. not sure what is causing the problemo. Maybe another set of eyes can help: [CODE] #include <iostream> #include <fstream> … | |
Re: The problem might be that ye' are breaking one of the rules on the use of default arguments. Here is a excerpt from MSDN: [url]http://msdn.microsoft.com/en-us/library/91563f79(v=vs.80).aspx[/url] [quote] Default arguments are used only in function calls where trailing arguments are omitted — they must be the last argument(s). Therefore, the following code … | |
Re: The name of this this post should be, "Challenge, Who will do my homework." | |
Re: your professor prohibitied the use of arrays, but there are many other data structures you could consider, such as string, vector, linked-list, queue, deque, and list. (cstring could be considered use of an array) | |
Re: your code is based on the premise that cin extraction into an int datatype is '.' delimited, but i believe that this is not the case. the bulk of your problem, in my opinion, occurs at line #7 when the program attempts to assign a huge multi-decimal number into an … | |
Re: your code is very, very, very, very, very, hard to follow because you did not use code tags when you posted your code. The result is your code that is not indented, looks like regular text, and contains smiley faces. i suspect you are trying to return a char in … | |
Re: I'm no math wiz, but here is another approach to consider: Based on your above example of 12.745, you could extract the decimal portion, and put it over its place value. In this case, the .745 has precision to the 1/1000 place (the last digit is in the 'thousanths' position) … | |
Re: [CODE] #include<iostream> #include<cstdlib> #include<string> #include<vector> using namespace std; class Vehicle { public: Vehicles(); void get_line(ifstream&); void display_data(); private: string make; string model; string plate; string registration_date; string keeper; string license; int wheels; double weight; bool is_taxi; }; int main() { Vehicle temp; vector<Vehicle> vehicles; ifstream infile("data.txt"); //Provide simple error checking … | |
Re: [code] char yes_no = '\0'; char again = '\0'; int counter = 0; struct Employee { string first_name; string last_name; int phone_number; bool is_salary; float pay_rate; char dept; } emp_array[20]; do { cout << "\nenter first name: "; cin >> emp_array[i].first_name; cout << "\nenter last name: "; cin >> emp_array[i].last_name; … | |
Re: between lines #8 & 9 insert do{ at line #90 put }while(x != 3); | |
Re: [code] input in; string temp; double d = 0.0; while(infile >> in.model) { infile >> in.steps; infile >> in.timehorizon; infile >> in.S; infile >> in.u; infile >> in.d; infile >> in.r; infile >> temp; in.instrument.push_back(temp); infile >> temp; in.exercise.push_back(temp); infile >> temp; in.position.push_back(temp); infile >> temp; in.type.push_back(temp); infile >> d; … | |
Re: Based on your example above, I see no benefit in reading the file in reverse. In my opinion, you could just as well read the file normally and process desired data after "order". But if you really want to.... I would probably just load the file into a vector and … | |
The End.