jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You're mixing together two different things here. Lines 5-8 can only be used in C++/CLI code (C++ with .NET CLR) http://en.wikipedia.org/wiki/C%2B%2B/CLI.

See http://stackoverflow.com/questions/236129/c-how-to-split-a-string for examples of how to do what you are describing. Here's a reference for the istringstream they use in the first example http://www.cplusplus.com/reference/iostream/istringstream/

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Use str.str().c_str() instead of str.str() on line 26. You need the std::string value represented as a C-style string ( char * ) and the c_str() method gets you that.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You have your opening brace before int main() instead of after it

Please start your own thread next time instead of bumping one that is almost 6 years old.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
double test1, test2, test3, tes4, test5;
	
string line1, line2, line3, line4, line5, line6, line7, line8, line9, line10;

Look into arrays for these quantities.

Also, when you have:

double& mean1, mean2, mean3, mean4, mean5 , mean6, mean7, mean8, mean9, mean10;
char& grade1, grade2, grade3, grade4, grade5, grade6, grade7, grade8, grade9, grade10;

see the following example:

double * a,b;  //I made this a  pointer instead of a reference but you get the idea
it's equivalent to:
double * a;
double b;

I do not believe you are correct in declaring lines 24 and 25 as references. Simply declare the "char &"s as chars as that is what your function is returning. Use arrays for these as well.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Change line 4 to:

string str = "ABCD";
P1.Inverte(str);
kunkunlol commented: Saved my day rofl +1
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Is that error still listed in the box? If not then it probably fixed it. But...it sounds like there are other issues with the code so there is no way to be sure. Knock out some of the simpler ones and see if the others go away.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Not a clue on that one. I haven't used XNA. Check around the area in which you are accessing "content" and then check your Game class to make sure the types match.

This doesn't necessarily mean what you changed was wrong the error checking may have finally caught up after you fixed the first one.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

See if something like this will work for you:
(tags is a List<string>)

XmlReader xmlr = XmlReader.Create("Yourfilenamehere");
while (xmlr.Read())
{
  if (xmlr.NodeType == XmlNodeType.EndElement)
      tags.Add("/" + xmlr.Name);
  else
      tags.Add(xmlr.Name);
                
}

Then loop through and delete all the empty entries. After that use the string's replace method (I suppose you could use the RegEx one in one step) twice, once replacing "[" with "" and once replacing "]" with "".

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Try changing line 1 on the first listing to public class puzzlepiece{ . I believe .NET classes default to internal (meaning things in the same assembly can access it) but the compiler may not be content with that.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Not a bad first effort but there are a few things: main() always returns an int, and is not void.

You need to specify that you want &arayvalues[n] on line #10.

Your second loop should be to 10 unless you want to add only the first 5 values together. Give yourself a small challenge and see if you can do it all in one loop.

Finally, just a stylistic thing but n = n+1 is usually abbreviated n++ (same for i obviously). If you want your code to be C89 compliant you should move line 12 up after line 6, at the top of the block with the others.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Here's an example of using ADO.NET (it's using VB.NET (viz AD's post) on an ASP.NET page but just ignore the ASP.NET part). You could use it with C++/CLI but that will require picking up some new syntax. If you have the fancier versions of VS (Professional or Team System or their equivalents in 2010) you can use VSTO to hook directly into Excel, but I don't know much more about it than that.

Hopefully that gives you some ideas.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Are you allocating memory within Vector3? It could be an issue with the copy constructor/operator= but that's just hazarding a guess.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Excel can generate plain text files in CSV (comma separated values) format. You can use tabs or spaces also (though you must choose one of the three I believe).

There are libraries out there that can give you more bells and whistles but you might not need that.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Learn more. :) In a more concrete sense what I believe firstPerson was indicating (but I don't want to speak for him) was that you should look into using an array for the months so, int months[12]; instead of all your separate variables and January would be months[0] . Look up enums in the long run to do what David was suggesting, but getting the arrays in there will go a long way towards consolidating that code. See if you can come up with a single "getter" function to get any month you specify rather than one for each month. As David mentioned look into vectors instead of the array for more flexibility etc.

The second point that FP was emphasizing is the "is-a" /"has-a" ideas of inheritance. Normally to have the kind of relationship you have designated (with Monthly inheriting from Customer) is an "is-a" relationship. If you had a class vehicle and derived motorcycle from it you could say a motorcycle is a vehicle. A better approach for you would be to have Monthy "has a"n array of customers (or even better a vector of them), which involves something like:

class Monthy
{
   public:
        //methods here
   private:
        Customer customerbase[25];
        //or   std::vector<Customer> customerbase;  //#include<vector> for this
}

which illustrates composition.

Hopefully that gives you something to google on. Post back as stuff comes up.

mrnutty commented: Sometimes, I'm too frustrated to say much. Thanks +5
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You have your break on line 22. Regardless of what happens with the choices you will always break out of the loop. So if the user chooses 1 or 2 you'll hit the break and exit out of the (outer) while loop.

My interpretation of what you are trying to do is that if the user selects 2 the loop will cycle back for more input. Therefore, if you move the break on 22 between lines 20 and 21, the code will then break out of the (outer) while loop (after lines 6-19 has taken place) and your function will return.

I think I might have been ambiguous in saying break before, I don't mean the inner while used to read in the file. For that one you can move what's in line 10 (minus the ; ) right into the loop condition instead of the .eof() call.

This is the word on .eof http://www.daniweb.com/forums/post155265-18.html

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

For .NET you can use a System::Diagnostics::Stopwatch It has Start() and Stop() methods. Use the property ElapsedMilliseconds to get the amount of time. See http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.aspx.

There are other ways to do it but they are not all compatible with the managed code (there are some Win32 API calls that you can P/Invoke for example).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Move the break on 22 up into the if statement otherwise it will break regardless of good input or not.

Put in a cin.ignore() before the cin if it's holding onto the newline character. Here's a good reference on cin.clear() so you can see under the hood a bit (http://www.cplusplus.com/reference/iostream/ios/clear/).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

AHA! I was missing a semicolon on a header file. Darn JAVA programming ;P

I don't quite understand what you mean by "What does setupPlayerInfo belong with". You mean what class? It is part of PlayerInfo.h/PlayerInfo.cpp

It didn't have a PlayerInfo:: in front of it, that's all.

I'll look into coding the do-while loop. Would it look something like this?:

Do (setupPlayerInfo()) {
// code here
cin.clear(); // needed for clearing the input to avoid an infinite loop?
} while (choice != 1)

It'd be within setupPlayerInfo, actually. cin.clear() is used when you've taken in bad input in the sense of looking to read into an integer and someone types characters. Wrap the loop around lines 9 through 46 and at the end of case one, set a flag to exit the loop.

bool breakflag = false;
do{
   //get input here
   if (choice == 1)
   {
      //all the stuff from case 1
      break;
    }
}while(true); //loop until break is hit

There will be some more rearranging necessary but that's the gist of it.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You've probably omitted a semicolon after one of your class declarations in the header file. See if that fixes both errors, otherwise you can post back with your new error message. What does setupPlayerInfo belong with?

Also lines 40 and 44 set up recursive calls to the function. This is not the best approach. Wrap your data entry portion in a do while loop.

There are other minor issues like with .eof() but let's get the heart of the problem figured out.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Let me clarify that I quoted the post for the sake of quoting the post, not as a reflection that the code was correct, but good catch NP-complete. However, try not to give the OP something they can compile and turn in for a grade.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

:( i tried but i doesn't work

this is my code

int num,count = 1;
cout<<"Please enter a number: ";
cin >> num;
while(count > num){
cout << " " << count;
count = num + 2;
}
cout <<"end";

Evstevemd is right in that it shouldn't be count > num. When you have a loop statement like that, each time through, it's asking that mathematical statement like a question.
You have it as count > num so it is skipping over the loop as he said (as things in the parentheses that are false cause it to stop).

You want to ask "is count less than num?" ( count < num ) if that's true, then that's the signal to keep going. Once you've reached the end of the range and it's false, the loop will stop.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

change this line

int num,count = 1;

to

int num;
int count = 1;

They are identical.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Declare the variables in your class without giving them a value. Define them in the constructor for the class. Then they won't have to be static.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

EDIT: Our posts crossed. Glad it worked.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

umm...couple of ways, first is the easiest.

//option # 2
string path = "AMBER/data/runx/amhsk_run*.root";
string runNumber;
cin >> runNumber;
path.replace( path.find('*'),1,runNumber) ;

I think OP wants to replace both x'es. It doesn't change your code much but you'd need another find statement (and you'd have to adjust your replace call if runNumber was multiple digits, unless I misinterpreted it).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I would imagine it would be TFile y(ss.str()); . If TFile takes a null terminated string then use ss.str().c_str()

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Are you looking in the debug subdirectory of the project?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Where is getData() defined (or declared for that matter). There may be a mismatch somewhere.

Why do we have these unresolved externals?

Would you rather your program run without the appropriate functions? ;)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Use a stringstream:

#include<sstream>
//...
stringstream ss;
string first = "AMBER/data/run";
string middle = "/amhsk_run";
string last = ".root";
ss<<first<<x<<middle<<x<<last;

Use the ss.str() to get the string back.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm confused what you mean by "a value set." I would think you would want a new instance of the array for each object. Was it set up in C# like that?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Why are you declaring your array as static? There's only going to be one copy over all the objects of your class.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You need something like this http://pdcurses.sourceforge.net/. You may have to compile it but it says there are some binaries available.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You don't need the .eof() loop, the getline will return null when it runs out of lines. In fact the .eof() can end up reading the last value twice (see http://www.daniweb.com/forums/post155265-18.html).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Try putting it in a winforms project by itself as the code for a button click handler and see if it works. Otherwise there could be something in your code that's preventing it (unless for some reason it won't let you go to 0 due to window thickness but that's just idle speculation).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If it's a ref class you need array<myclassname^> (^ is a pointer to a garbage collected value). There are some great tutorials over at http://www.functionx.com/cppcli/index.htm (their winforms stuff is kinda mediocre but the language stuff is pretty thorough).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I put the code you posted into a button click method and when I clicked it, the window went to the lower right hand corner.

I try to do This->Top = 0; no avail.

What happens when you do that?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What's the error message that you are getting?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Here's the correct code for the 2nd program

int num;
cout<<"Please enter a number: ";
cin>>num;
for(int i=1;i<num;i=i+2)
{
cout <<" "<< num;
}
cout <<"end";
    return 0;
}

Please don't give away the answer if the OP is working towards it. Your code is also incorrect. Test it out.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

See http://gmplib.org/ (or use MPIR for Visual C++ and mingw without cygwin)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

And to tackle the problem of getting the string size, you could get the string class to return the character array of the string, and then use strlen to find the length of the string

Or use the .length() member of your string.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You forgot to change radius to radiusMain on those 3 lines.

Also, please use code tags [code] //code here [/code] when posting your code to preserve formatting and make it easier to read.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Hello there,
for working with images I like to use the OpenCV library, it's very simple
and powerful.

Cheers!

For .NET you would need a wrapper like http://www.emgu.com/wiki/index.php/Main_Page (there are a few others but that one is recently maintained).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

great
another point overhere .. :)

i'm trying to write to file ok
then i used a streamwrtier then try to write to file some characters .. and they were written successfully
but when i tried to read them as byte i faced a character byte with value 13 .. i didn't write it
as eg. i white in my code

strmwrtr->writeline("P2");

i found
80 = P then
50 = 2 then
13 -----> my problem
i searched the net how can i avoid this .. but .. nothing

WriteLine() puts a "\r\n" after your text. Use Write() instead.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Please post what you have done so far. If you are missing the formulas a quick google should bring those up.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It's called a "handle" which should make searching for info on it a little easier.

Here is a good reference: http://www.functionx.com/cppcli/handles/Lesson04d.htm

It's basically just a designation that the pointer will be garbage collected (so the variable will be allocated in the "managed heap" -- C++/CLI has both a managed and an unmanaged heap).

String^ is the type for regular ol' strings in C++/CLI so you could have:

String ^ str = "Hello";

It's not a character array either, it must be transformed into one with the toCharArray() method (doesn't put a null at the end).

So the argument array for Main is a handle to an array of string handles.

It's a peculiar dialect of the language for sure.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

No, this is not possible. You could have an array of size Nnamed entry and have entries 0 through N-1.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Unmanaged arrays can't hold managed objects (and vice versa) due to garbage collection issues. If you are going to exchange data between the two it has to be marshaled.

Your best bet is to have a class member that's a cli::array and initialize it in the constructor of your ref class. You can pass the number of objects in the array,obtained from wherever, into the constructor.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

i searched for

Answers are on MSDN:

is list<T> act as array in memory

http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx

linkedlist<T> acts as linked list in memory

http://msdn.microsoft.com/en-us/library/he2s3bh7.aspx

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

do you also use the pages from the books as a alternative for toilet paper :P

No, since how would I see over the wheel? Also, the table would wobble... gotta have priorities.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Delete the timer from your form. Drag a new one from the toolbox onto the surface of the form, the icon for it should show up below your window in the designer in the gray box (you could just modify the existing code without adding and removing it but this makes sure all the automatically generated code is what you need).

Select the timer icon and go over to the properties window on the right hand side. Click the lightening bolt. Go to the cell next to Tick and double click it. Now you'll have a handler for your timer event. You'll need to set the interval for the timer either in your class constructor or in a Load event for the form. Then use the timer1->Start(); and timer1->Stop() wherever you need them.