jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Look under:
Project Menu/Properties/Configuration Properties/General/Output Directory

I think this is to what you are referring.

Also see Project Menu/Properties/Configuration Properties/Debugging/Working Directory

I'm not sure what the exact distinction between those two is, but the latter might let you just specify the directory for the dlls without having to spawn the exe there.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Are you able to access the return value from your function in the main program? [EDIT] I tested it out and it looks you can.[/EDIT] I had some trouble getting something meaningful back (like for your bins value in main()) but if you took care of it with the output in your function all the better. Great going! I think it had to do with the array in main being passed in before it was initialized.

2s complement is no big deal:

say I had the number 10 (assume a 32-bit integer)
00000000 00000000 00000000 00001010
take the 1s complement (toggle the bits)
11111111 11111111 11111111 11110101
add one to the 1s complement
11111111 11111111 11111111  11110110 
set a signed     int = 0xFFFFFFF6 (the above number in hex) and print it out you get -10
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

There's what looks like a good book.
http://www.amazon.com/Googles-PageRank-Beyond-Science-Rankings/dp/0691122024/ref=sr_1_1?ie=UTF8&s=books&qid=1263791443&sr=8-1

In addition to books like the above, for the theory you can probably dig up quite a bit right in the SEO section of our beloved DaniWeb. Those folks earn an impressive living knowing the ins and outs of google in particular (though I suppose bing people are probably out in full force as well).

I don't know of any open source projects about this but there's bound to be something.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You'll have to have an embedded character especially for eyerolls (à la Narue). It would be like the letter e of sarcasm.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Datafile, etc. in main() bear no relation to the names you have given to your parameters in your method definitions. Just make a variable of datatype OUTPUT_t and one of DATAFILE_t within the body of main()and pass them into your methods. These variables are being passed in by reference so the reference will be to the two variables in main() as they pass through the methods.

cStudent::cStudent(); is incorrect. When you are declaring your tempstudent on the line before your default constructor is already being called.

Also main() should explicitly be defined as returning and int and should have a return 0; at the very end.

P.S. Please use code tags or highlight the code and hit the [code] button on the toolstrip of the editing box.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm not sure what you mean when you speak of converting negative numbers.

A negative decimal number is represented in the computer by a system called Two's complement (see http://en.wikipedia.org/wiki/Two%27s_complement). In order to find the 2s complement you toggle the bits of the binary representation (1-> 0 and 0->1) and then add 1 (binary) to the result.

If what you are trying to do is be able to accept negative numbers from your user and just declare that -5 is -0101 (which as stated above is incorrect) then just test if the value entered is less than zero and multiply it by -1 and convert.

So, the method unsign confuses me a bit. Your logic for converting (positive) numbers seems to be fairly sound but I haven' tested it yet. To get some ideas (resist copying) for how other people have done it search on the site as this is a common problem (it seems having your own version is a prerequisite to register on DW!).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Gotcha, yeah that's um creative. And thanks for keeping SOHCAHTOA alive!

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

When you select a project go for Win32 Console Application, deselect precompiled headers and leave empty project unchecked. That usually takes care of it. I'm behind on the times as I don't have the latest and greatest yet but seems to me most of that is unchanged.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Where did you get that number from?

btw, it doesn't really matter per se but the functions are called sine and cosine, a sinus is for example the empty space behind your nose and upper cheeks.

Have you done some calculus? Have you heard of Taylor Seres?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What are some of the ideas that you have had? How would you try to do it if you had to?

EDIT: Shawn nice idea in principle but unless OP is doing right triangles...

@OP: How could you get the tangent knowing the other two?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Whoops that was done on autopilot. Thanks Lerner. But do set it to zero before your loop.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I would drop the istringstream it's complicating things when it's not really necessary. I changed a couple of lines in your code, specifically the while loop condition

while(fin >> x >> y >> z) {
	   	row.push_back(x);
		row.push_back(y); 
		row.push_back(z);
  
                 //... rest is the same
          }

And added: cout <<fixed<<setprecision(10); before your output (around line 32).
You were getting the digits it's just that cout didn't know how many to display. (add <iomanip> to your includes for those methods).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Sold separately? Goes with: Batteries not included. Some assembly required. You need at least 2/3 of those to qualify for a 1980's toy commercial.

So rather than your recipient think you're being sarcastic, they instead think you're an idiot who can't use a keyboard.

"nt nlik ne1 els w no"

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

In your driver you can change:

bool ok = ReadFile(names, rTotal);

	// This loop is to make sure that the data file was opened successfully.
	if(ok == false)

--to--
if(!ReadFile(names, rTotal))  //not overly compact but helps someone 
                                 //see the two steps in one

The main problem hampering you at the moment is in 73-76 of your "Functions.cpp" file. Line 73 is attempting to read the first line of the file (a name) into a character variable. That name value is being interpreted as 7536754 What you want to do is put in a while loop:

int rTotal = 0;
while(FirstNamesInput >> names[rTotal])
        rTotal++;

That will give you an accurate count.
Just a suggestion: you don't have to use this index i - 1 stuff, arrays are all 0 based, it hasn't changed in 40 some odd years, probably won't.

Another hint: when you're in this debugging stage knock your list down to 10 or so names just so if you have to step through it 100 times it won't be as much.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You need a ; on the end of your class declaration.

class expenses {


};

You have it right that "getters" return something but you need to indicate that on their declarations and definitions (i.e., what are they returning-- they're not void). You need to just get the private values and return them. You'll need separate "setter" methods that take in a parameter and set your private variables to that value. In turn those won't return anything.

EDIT: Do NOT bump your post 2 minutes after posting it! There is no point and it makes people less likely to want to help.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Also make sure the compiler is in the path of whatever cmd console you are using. Under windows (I assume, since you have C++.exe) type "PATH = %PATH%;C:\MinGW\bin" (change the values for your system) which tacks that directory on to the existing path

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Sorry, got any hint?

For what??? Use multiple cout statements or a debugger to see what is in those variables. If it's not the right thing trace it backwards until it's right again. I will not spell out every last little detail for you to pick up. I am assisting you but I'm not your assistant.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Would something like this work (if you used Visible = false in your resize method instead of Hide())?

private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
        if(this.WindowState == FormWindowState.Minimized)
               this.WindowState = FormWindowState.Normal;
       this.Visible = true;          
}
j4jawaid commented: Thanks. +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

outfile << i + 1 << endl; // This is for the running nos (1,2,3...etc), correct?

I'm not sure why you had it there but I gather you don't want to write them back out to your binary file again. That will write your number and then a newline before you write the other data.

Program Crash after inputting this line

Go back and make sure you're reading in the data in precisely the same order that you wrote it out, read doesn't know anything about your file except what you tell it (I want to write these bytes into wherever and the data structure is n bytes long). Failing that open up the binary file from which you are trying to read in a hex editor like Ancient Dragon had suggested.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

outfile << stu [i].st.uks.noTEST & outfile << stu [i].st.oss.noTEST; They are not defined anywhere in this method! You seemed like you were trying to read them in from the binary file but you didn't write anything like that into it. afile << i + 1 << endl; This is still wrong.

Do some cout statements between your read and output to text to make sure those variables were successfully read in with the Read() method.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Ok. Check out my edit to my last post. Check your output to make sure it's giving you what you want, but that's what I had been trying to explain to you. My sense is that without null termination cout will display a portion of the next string as well but I may be incorrect on this.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I told you repeatedly that you do not use write with text files and that is what you are doing on 164-171. Just to clarify, process_text is supposed to be reading in the binary file you wrote in the prior method, correct? We may have gotten signals crossed here.

Try them like outfile << stu [i].st.oss.country;

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Really can't open the binary file & generate as text file in a single function?

I don't believe so. Make life easier on yourself and use your new ofstream as text. I'm not sure what your hesitation is.

ofstream outfile ("updateoutfile.txt", ofstream::binary); is contradictory.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Check and make sure that you are not reading both the country of origin and the name into the 30 character array. I fixed the problem with a call to get() instead of a >> in the while loop condition and a .ignore() call afterward to get rid of the space between type and country.

I've managed to put in the '\0' characters in the proper place by using the gcount() method of the input stream, keeping an array of the character counts for name and country for each i.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you file is text for your last function, why are you writing to it as a binary file? You can't mix << and write() or at least not for your desired result. So, open the outfile as text and write to it using << and your char arrays (which again, I remind you are not null terminated so implant a '\0' in a spot where you believe the characters have stopped.

If there's still a problem, put some cout statements in your program at strategic points (or use a debugger) and make sure all the values are being transferred in and out ok.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

1.) I would just do ios::in | ios::binary

2.)You need the binary because you wrote it out in binary and you need to read it back in that way.

3.) If you can I'd create the fstream objects within their respective methods and not in main. For instance for your text out, make an fstream with ios::out and nothing else.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

For which part?

btw, There's a way you can look for references too :)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Your IDE is trying to run the compiler contained in Visual Studio. "cl" is how you can invoke the compiler from the command line.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

[sarcasm]
No he and his wife don't get out much.
[/sarcasm]

http://www.gatesfoundation.org/Pages/home.aspx

and from Wikipedia: "The Bill & Melinda Gates Foundation (B&MGF or the Gates Foundation) is the largest transparently operated[5] private foundation in the world, founded by Bill and Melinda Gates."

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

afile.open (filename, ios::in | ios::out |ios::binary); //you probably don't need the ios::out, just make another fstream for your output with no binary. I would at least for the time being read your variables back into a fresh array of structs in case you need the other values later.

One thing you need to consider, you need to null terminate your character arrays (so stick a '\0' after the last character) so that they will be usable with the << operator for the output stream, otherwise you'll get lots of extra characters and you might run over the subsequent arrays in the process -- either that or you'll have to use the put/seekp/etc and put out the char array one char at a time.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The top display is for which file? I don't quite understand the word in bold.

That would be the equivalent to your outfile.dat.

When I said actual struct I meant (sorry for the mixup) the (name, country) data from your struct. I say actual becauase what I had done was made up another struct with an int and a double and written that to the file after I wrote out the name and country. I wanted to see if I could get the "blocks" in the output and I did because the binary representation of int and double doesn't translate readily into human readable ASCII when notepad tries to read the data.

Will I be using codes like afile.seekg, afile.seekp...etc?

I am not sure if you need them if you read everything back in and write it out in the proper order interspersing the new data with the old. To read it in, you need to use the read() method of your input stream (make a new input stream for binary) in a similar way to how you wrote it out (designating a destination for the input and length). Then use the << operator with a new output stream (don't designate it for binary).

Give this one a try without the examples (or look at the quick examples on http://www.cplusplus.com/reference/iostream/fstream/ . Come back with some code and any questions you have.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

That should not matter.

That's my bad. I guess I had never seen it done that way. Apologies to the OP.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Some general things because this doesn't even compile (which I think you implied):

Lines 40 and 44 of your driver program, you don't need to put the return type in front of them when calling your methods in main().

Wrap your header file in:

#ifndef P1_NAMESEARCH_H
#define P1_NAMESEARCH_H

//the rest of your header here

#endif //at the very bottom

and don't include the cpp file in tho other one, instead include your header file in both the functions.cpp and the driver.cpp.

In your header, just pick something for this last parameter to this function (you can always change it later) so it's working to the point that you can begin to play around with your program to test changes. bool SearchNames(string names[], int *pTotal, *pUserInput); I know this is not exactly what you wanted but it will make it easier for someone to help you then they don't have to go wading through a bunch of errors.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

So do your bubble sort and allow the other array to follow along (when you're update index numbers for A array in your sort, update B with the same changes.

Then comb along A (with a loop) and find the first set of duplicates (check index n versus index n+1, and n versus n+2 if there's a match).

Over those index numbers do a mini bubble sort of the B array (since the A values are all the same leave them in place and just sort the select B values). Move on to your next set of duplicates, etc.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I think since the other array must track the indicies of the first it would be difficult to use the STL methods anyway. What are some of the things you have tried?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Also, your method definitions, e.g.,

void dayOfTheWeek::printDay()
{
	cout << "Today is: " << day[dayNum]  << endl << endl;
};

and onward should not end with a semicolon after the brace (you do still need the ones at the end of your class declaration and your const array).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

afile.write(&stu.type,1); // Why the '1'?

since we a writing a char (defined as being one byte) that's how big it is (so sizeof(stu.type) = 1), just like when you had to call is like afile.write(arr,MAX); when you had MAX number of chars in the array.

when open in notepad, they are not a bunch of black blocks.

I got something like this:

U Michael_Owen                 O          Australian David_Cooper       O          Japanese Arikato

The spacing comes from the extra room left over in the arrays. The fact that they remain as letters shouldn't be a surprise, as notepad's job is to interpret a file of characters and display it for the user to read. Try putting a struct of ints or doubles into your code and writing that out after your actual structs. I did that and got a few "black blocks."

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

afile.write (reinterpret_cast <const char *> (&stu[i].type), sizeof (n)); Since stu.type is already a char you can simply do afile.write(&stu[i].type,1); Try this change and move it in front of the other write() statements. Failing that, I would double check your input results (loop through and print out the parts of the struct) just to be on the safe side.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

That seems to be right the way you have it. What problems is it causing?

I was also suggesting that you write out the type (accessible via pointer as &stu.type to pass into the write method) into the file so that when you are reading it back in, going along you can know whether to read 1 or 2 char [] for UK or non-UK students.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yes. Except your last write statement where you try to write the whole thing may not be working the way you want it to. That is to say I'm not entirely sure that it will.
Remember to put in an if statement amongst your other write statements because you won't write out a country for the UK students. You may need to write the type of student into the file as well. Convert your char U/O to a char * for that. You'll be reading them in (or someone will) but I suspect as long as you can somehow tell what kind of student it is you should be ok.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

See post #6 of this thread from the Ubuntu forums:
http://ubuntuforums.org/showthread.php?t=976202

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You have to use the read() and write() methods for binary files so getline will defnitely not work (it doesn't work for text output either).
See http://www.angelfire.com/country/aldev0/cpphowto/cpp_BinaryFileIO.html for some examples (towards the bottom of the page). For your purposes you could probably just write the members of the structure out rather than trying to do the whole thing (like in their last example).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm not commenting on anything more until you put code tags on it. I showed you how, there's no excuse.

Salem commented: You tell 'em! :) +18
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

"that if the lost amount is greater than balance left than balance only becomes 0 and not go into negative values."?

Your lost amount is balanceLeft (which I think you should rename to loss or something because it doesn't reflect your balanceLeft at all)
So, if (your loss is greater than balance) make the balance 0 else balance equals balance minus loss.

The incorrect thing you did in the second one was setting balance equal to bet. There's no rhyme or reason for doing that. As I had said that's like saying if you've won 800 so far and bet 25 and win and I suddenly switch your 800 for 50 instead.

You need to check how many times your do/while is running and read again the criteria under which it is supposed to stop.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

afile.getline (stu [i].st.oss.country,MAX,' '); is the only change I would make, as your country and name are separated by a space so to stay on the same line ' ' is needed.

You can set stu[i].type = n; (or read into stu.type with your loop condition (afile >> stu.type instead of afile >> n).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Please use code tags. It keeps it neater and preserves your formatting so we can read the code.

Make balance and bet doubles also, as what if I lost 20.50 in the process or wanted to bet $4.50?

cout<<"Please enter your bet$100.00):"<<endl;
//hint this line should be updated for each pass through
[/code]
I don't think there's much point in doing this
[code]
for(int index=0; index<RAND_MAX; index++)
{
      randomNumber = (rand()%10)+1;
} 
//just remove the for loop
[/code]
[code]
balance=bet;
cout<<"You win $"<<balance<<endl;
balance=balance+bet;
//so if you've won $800 so far and your bet was $20.00, after you've //won you're balance would be $40.00??

I'm sure there might be other stuff but I can't have all the fun. The important question to ask is "does my output match up with the sample output exactly?"

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

When you have an array you declare it as type arr[size]; When you access the array you put in the desired index, e.g.,

int arr[5]; // holds 5 elements
                 //but the first element of an array is arr[0]
cin >> arr[5]; //INVALID since arr[5] is the 6th element of the array
                       // no such thing

now with:
afile >> stu [i].st.uks.name [MAX1] ;

you're accessing stu so far so good, member st.uks, ok that's valid, and now you try to access the name member, but at MAX1 which is one index too far (at best you'll hit another initialized area of memory but at worst your program will crash and burn).

So your ifstream statement is trying to write the name you read in from afile, but read it into a variable that's only 1 char long (accessing name[index] only give you one char out of your array) and into a character that you don't have the "rights" to.

Enter getline. Did you read the reference at all? This is a method that will help you read into your char arrays from the file. afile.getline(stu .st.uks.name) (NO index this time) will read from your afile into name. Read the reference about delimiters and decide how to separate one line of your text file into multiple "lines" to read into your variables (hint: what separates the country of the student from his/her name).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Break it down without the constants. You've declared an array of size 30 up above and you're trying to access the element #30 on lines 76-81. Except the index of element 30 is not 30, it's 29.

Nonetheless even if you had the proper index, you are reading into your char array incorrectly. Look up how to use the getline() method of your stream. See here for details.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Possibly, but in this case it did not. There was some excess in the input buffer that was causing the program to skip right past the get().

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Replace your cin.ignore(cin.rdbuf()->in_avail() + 1); call with cin.ignore(); cin.get(); the get() will wait for a keypress from the user.