jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Hint: what if your name input is not matched by the first line of the file? If they don't match keep going, reading in lines until it does. You need another loop.

Using "out" as the name of your input file might be confusing to someone (or you!)trying to read your program later.

Also, what happens if the file is not found or went bad?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Is there any requirement as to the ordering of the videos, or is it first entered goes into slot 0, etc?

The spacing issues and slashes are just basic modifications to your cout statements, what specifically are you having problems with in that department?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

To get something with similar function names and parameters try http://codecutter.org/tools/winbgim/. It's terribly outdated and you'd probably have to rebuild it with VC++ (I haven't used it with either compiler so I don't know).

Otherwise, David's and Mike's solutions are probably one of your better options.

If you search around in these forums, you might find some patch fixes to get it to work under your current environment, else downgrade your OS.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Why are you using methods meant for C-style strings (strcpy and strcat) when you are using std::string objects? Otherwise the gist of all the inputs and outputs looks ok. Look up the substr and find methods and what they give for results. Hint: the += operator will be helpful to you.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I think it's your formula. When I did it old school style by finding the mean and summing the square of (each element - mean), and dividing that sum by n, I got 9.54124 * 10^7, which is closer to your goal.

If you want to use the formula where you don't have to do it twice, find the mean of the squares and subtract the square of the mean (see Wikipedia).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What have you tried so far?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

When you give cin a bad input for "value" (e.g., 't' in your example), the stream goes "bad" and you need to issue a cin.clear(); after line 32 to reset it.

See http://www.cplusplus.com/reference/iostream/ios/clear/ (the example is for a file stream, but it's the same idea)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Hint: Write the bar graph out line by line. Draw out a sample by hand and see which values have stars printed on which lines. After you've figured it out using cout, send the output to your ofstream object instead. Give it a try and see how far you can get.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Your code is confusing. I'm assuming you assign a value to "a" in code you haven't shown, otherwise you're getting whatever junk is in "a" to begin with.

Why not just use rand() to generate a start time, then call it again to generate a random offset from the start time? Afterwards, add that offset to your start time to get the finish time.

Also please use [code] //code here [/code] code tags next time.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yep I have that in my main .cpp file. I'm sure I've read somewhere that Microsoft's implementation of it was different in Visual Studio forms?

There are type incompatibilities between the managed and unmanaged code. All of the old libraries are considered unmanaged, so you have to "marshal" the data returned by the std methods.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Check out http://msdn.microsoft.com/en-us/library/aa904305(VS.71).aspx to see how to use the Split() method of the string. You will form a string array with each of the different tokens at a separate index. Depending on what data type they are you may need to parse them (see http://msdn.microsoft.com/en-us/library/aa328656(v=VS.71).aspx for an example).

You are using the right method with the streamreader. I do not believe there is an overload of the >> operator for the string type in .NET.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

See http://cplusplus.com/reference/clibrary/cmath/pow/ for a reference. Watch out for the overloads that are allowed (i.e., there is no overload for an integer to the power of integer, so you'll need to do appropriate casting).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

can explain detail like write down the pseudocode and the whole c++ program.. thanks^^

This looks suspiciously like a homework assignment. Please let us know what you have tried first. Working the problem on paper will help you write the pseudocode, etc.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If the user inputs 3:00 pm you need to convert that into 15 hours on line 56 so that you can compare it accurately against your seconds up to 11:59 am in line 83.

Otherwise you are comparing 3 to 12, which is less than, thereby outputting your AM value.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Maybe (and I know this creates more work) try a SurveyMonkey thing with questions about "Which of the following group is most important to you as a reader of news on Daniweb" Raffle off some piece of Daniweb memorabilia to a random participant.

Or you could publish all of the articles under a byline of HappyGeek :)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The interviews are a great idea. I'm looking forward to the Stroustrup one.

It's hard to create a niche when there are so many other outlets. Insider stuff is always good but I don't know how hard that is to obtain in some cases.

I applaud your efforts but I'm personally at a creative loss as to how to see your vision through.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I think a majority of them are interesting but I like the futurist type things (I guess I am an "overall geek" as Nick put it). I'm not as captivated by things about social media.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It's not too bad:

Label^ lbl = gcnew Label();
//fill in the Location property (specify by System::Drawing::Point(x,y))
//fill in the Text property
Controls->Add(lbl);
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Have a look at something like this:
http://msdn.microsoft.com/en-us/library/1b4az623.aspx

This is one of those unfortunate cases where the unmanaged and the managed data types cannot be interchanged, you need to marshal the string.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I get the same restriction. It's too bad because that is a useful link.

jonsca, you do not have permission to access this page. This could be due to one of several reasons:

1. Your user account may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
2. If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Depending on what system you are using textboxes can be read only or read/write. What are you trying to write this in (Win32 API, MFC, Winforms)?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

See:
http://www.cplusplus.com/reference/clibrary/cstdlib/system/

The function returns an int that is "system-dependent" (could be an exit code for the program, could be garbage).

Perhaps write the output of the program to a textfile (using "samp -s1122 > text.out") and read that into your program.
I'm not sure if this is a case where you could use piping as that's beyond me.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
if(Atmos->SelectedText !=Temp->SelectedText)

doesn't work for it?

If you wanted to do it succinctly you could step through each of the controls on the form, checking to see if it's a combobox, then checking that combobox versus all the other controls. The best way to mark them is to use the Tag property since there's no "is" keyword in C++/CLI like there is in C#.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Are you trying to make sure that none of the comboboxes have the same value selected or if they have one of the same options for value that another combobox has?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The first error is simply a spelling error.

The next 2 errors are saying that your class is missing declarations for those variables.

Look at lines 43 and 44 based on other programs you've seen. How do they declare objects of a class?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

1) Which system are you using (MFC or Winforms or...)?

2) Where are the new values coming from?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

In line 18 for example when you have nem1 = (nom1/num1)*100; (more descriptive variable names might serve you better in the future) the nom1/num1 is an integer division so that something like 2/3 will yield 0, 3/2 would yield 1 etc (the decimal portion is tossed).

To alleviate this, cast one of the members of the ratio to a double. nem1 = ((double)nom1/num1)*100; OR nem1 = (nom1/(double)num1)*100;

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The best method (though I don't have any advice on it) is using a background worker: http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx

yoni0505 commented: thanks +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It's not even in response to anything, so the flimsy attempt to cover up the spamming becomes even flimsier. Of course by all of us replying to this infernal crapola we're boosting the reads of the thread. Should just have been deleted as garbage, IMHO

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I couldn't find any way to do it within the settings either.

Your best bet would probably be to do it within your code itself, taking into account the margin around the linklabel and positioning it at center of panel - margin of linklabel - 1/2 width of linklabel for the x coordinate, etc. In fact if you have many of them to center you can turn it into a loop.

Either that or do the calculations by hand and maneuver the linklabels in the form designer (I tried it and there doesn't seem to be any "snap to" lines that come up in the panel).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Under the Project menu: choose <projectname> Properties. Go to Configuration Properties. Under Linker/General: fill in the Additional Library Directories and under Linker/Input: fill in the Additional Dependencies with the .lib names

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It's relatively easy:

#include <sstream>
//...
int numbervariable = 10; //or double, etc. or use your loop counter
std::stringstream ss;
ss<<"Firstpart"<<numbervariable<<"Secondpart"; //use it just like any other stream

std::cout<<ss.str()<<" is the string portion";
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Check out this thread.
http://www.cplusplus.com/forum/general/3570/page1.html#msg15410

Basically you're stuck with platform dependent (non-portable) solutions. Using a library like ncurses(on *nix) or pdcurses (http://pdcurses.sourceforge.net) would give a slightly more portable solution.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Mixing getline and cin can lead to this problem (I thought you meant you compiled the example on the cplusplus.com site and it gave you trouble).

Put in a cin.ignore(); before the getline. There is an extra '\n' left in the stream after the prior cin that the getline() then reads in and then terminates thinking it's the end of the input.

When posting code please use code tags [code] //code here [/code]

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I already had tried this sourcecode from "]http://www.cplusplus.com/reference/string/getline/" and it doesn't work. When I execute his sourcecode it just go through without askin' 'bout requestin' for data input. You can read "thank you, " but no data contain in the string variable str.

Post the exact code that you used.

Sorry for my scriptural English. If you have char or cha a [8] with this value "aaa aa a". How should i do to convert it into string included with white space?

No big deal. You can use the constructor for string that takes in a const char *

char str[] = "hello";
string stdstr(str);
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

use the getline function to get input with a space http://www.cplusplus.com/reference/string/getline/

What do you mean by "in the char it also contains white space"? What are you trying to accomplish?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Search "c++ has-a relationship"

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I wish there were a website in which you could type in a concept or idea and it would give you websites with related topics.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

This is an ideal situation which which to use stringstreams. Are you locked into using the characters array?

Also, itoa is non-standard so it's not guaranteed to be available on all compilers.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Put your code in an infinite while loop (using while(true) ) and break out of it when you want to exit. All of your function declarations would stand anyway and global variables would persist during the program execution, so I'm not sure what you mean by that.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I think it was intended for Computer Science, for better or worse. I had flagged to it to be moved...

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Your temparray is exactly that. It's created within the local block of the function and destroyed when the function exits, unfortunately.

Pass in an array by pointer so that your function signature looks like

void arrayfunction(float arr[],float flt1,float flt2,float flt3)
{
   //load up the array here

   //still exists on exit

}

I suspect since you are using opengl that your function is really more complicated than this.

What you have above could work with some modifications, but I think the above way is much more straightforward.

scar164 commented: Thanks for your help! +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Your syntax is out of order here:

car * cars[strcture] = new car;

The syntax is incorrect here (look at the examples in your book and even within your code more closely).

while(count2 =! strcture)

If you're making a while loop, make the index variable and the count variable one in the same. In this above example you have count and zero2 and zero and they are all mixed up.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Check out http://en.wikipedia.org/wiki/XOR_cipher. I think that's what the assignment is trying to get you to do.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yeah getting a steady distribution of 0s and 1s is difficult. I wish I could elaborate more on the theory about that but I believe it has something to do with the lower order bits problem that Narue describes.

Solved threads is how many of your posts on other people's threads that end up being solved. So, as it stands anyone that has posted on that thread (besides the OP) before it was marked gets credit.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Are you drawing numbers in between 0 and 1 or just 0 and 1 themselves? I'm not sure about biasing the selection. I suppose,for example, you could generate a random floating point number between 0 and 1 and if it's greater than .33 output a 1 and less than that make it a zero. That would give you roughly twice the number of 1s.

However, I'm certain there's someone that has dealt with this more than I have and so I don't guarantee this to be an ideal solution and there's definitely a better way.

In the meantime check out Narue's great tutorial on the subject: http://www.eternallyconfuzzled.com/arts/jsw_art_rand.aspx

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Check lines 64, 77, and 98.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Why not copy it all over to a char array, substituting the '*' for and integer value of 1 and converting all other integer values to characters (assuming they are all one digit)?

I mean technically chars are integers so you could store you asterisks as 42 in the int array but then your 1 values would have to be 49 to remain consistent. If you were to try to output the array by casting it your 1's would end up as a non-printing character.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What are the types of both arrays?

Also, the way you have it laid out if you hit a 1 on the first pass through the while you'll get stuck there (unless you are incrementing row and col somewhere else).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I have not read it, but I believe the Ivor Horton Visual C++ 20XX {05,08,10} covers some of the CLR-Winforms (in addition to MFC, I believe).

The winforms programming requires you to use an odd dialect of C++ (called C++/CLI) so I think a lot of people avoid it because it's clunky and it's painful to interact managed and unmanaged data.

M$'s evil plan is to have people use C++/CLI as a compatibility layer between C++ code and C# and do all the GUI programming in C#, or that's the way I understand it.

If you want to do your GUI programming in standard C++ you'd have to stick with either win32 API, MFC or a third party library like Qt or wxWidgets.