537 Posted Topics

Member Avatar for KanazawaFTW

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 …

Member Avatar for Clinton Portis
0
188
Member Avatar for xocpnytsirhc
Member Avatar for jvicta

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.

Member Avatar for NathanOliver
0
314
Member Avatar for TheNNS

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 …

Member Avatar for TheNNS
0
3K
Member Avatar for senergy

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

Member Avatar for senergy
0
4K
Member Avatar for ggreen33697

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

Member Avatar for Clinton Portis
0
113
Member Avatar for clide890
Member Avatar for imolorhe

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 …

Member Avatar for daddymummy
0
227
Member Avatar for opawix

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]

Member Avatar for namratag
0
105
Member Avatar for rcowboy
Member Avatar for Zssffssz

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 …

Member Avatar for NathanOliver
0
445
Member Avatar for hujiba

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.

Member Avatar for hujiba
0
121
Member Avatar for Adnan671

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 …

Member Avatar for Clinton Portis
0
295
Member Avatar for Nicko_FaTe_

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

Member Avatar for Nicko_FaTe_
0
162
Member Avatar for Mahkoe

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 …

Member Avatar for Mahkoe
0
182
Member Avatar for suraj_p
Member Avatar for suraj_p
0
179
Member Avatar for mattiapdo

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

Member Avatar for Sodabread
0
2K
Member Avatar for sadsdw

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.

Member Avatar for sadsdw
0
258
Member Avatar for amaanbhae

perhaps computer programming isn't the field for you. perhaps you should change your major to liberal arts or something.

Member Avatar for Ketsuekiame
-5
181
Member Avatar for wingwarp
Member Avatar for tiredoy
0
451
Member Avatar for spiritsad

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

Member Avatar for zaraki
0
184
Member Avatar for Derek Elensar

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

Member Avatar for Derek Elensar
0
1K
Member Avatar for shyla

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 …

Member Avatar for Narue
0
969
Member Avatar for NoUserNameHere

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

Member Avatar for Narue
0
112
Member Avatar for jeffpro

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 …

Member Avatar for Clinton Portis
0
217
Member Avatar for daianahoney
Member Avatar for piecykoos

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

Member Avatar for YouGotCaught
0
1K
Member Avatar for Saith

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 …

Member Avatar for vijayan121
0
307
Member Avatar for munitjsr2

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 …

Member Avatar for Clinton Portis
0
162
Member Avatar for butler273
Member Avatar for mitrmkar
0
201
Member Avatar for AODfan
Member Avatar for C++ Beginner

Try this: [code] char letter = 32; int counter = 0; while (letter < 128) { cout << letter << ' '; counter++; if(counter == 16) { cout << endl; counter = 0; } letter++; } [/code]

Member Avatar for furyrichie
0
2K
Member Avatar for mariusiacob

you've done everything for writing to a file, but there is absolutely no code for opening and reading from a file.

Member Avatar for abhimanipal
0
3K
Member Avatar for The physicist

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.

Member Avatar for The physicist
0
2K
Member Avatar for Clinton Portis

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.

Member Avatar for Narue
0
110
Member Avatar for Clinton Portis

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

Member Avatar for Clinton Portis
0
244
Member Avatar for edrag

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 …

Member Avatar for writerervin
0
1K
Member Avatar for Sahilroy
Member Avatar for techsurge
-7
125
Member Avatar for CrumbledCookies

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)

Member Avatar for ravenous
0
191
Member Avatar for Muhammadlodhi

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 …

Member Avatar for VernonDozier
0
1K
Member Avatar for cousinoer5
Member Avatar for teoh

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 …

Member Avatar for Clinton Portis
0
134
Member Avatar for Rickay

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

Member Avatar for Rickay
0
635
Member Avatar for Salamu

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

Member Avatar for Clinton Portis
0
136
Member Avatar for demigodz24

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

Member Avatar for vinayakgarg
-1
95
Member Avatar for exekiel101
Member Avatar for LevyDee
Member Avatar for jaglever

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

Member Avatar for VernonDozier
0
223
Member Avatar for MasterGberry

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 …

Member Avatar for MasterGberry
0
105
Member Avatar for sadia.ab

The End.