jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

@masterovpuppetz: Did you happen to catch any of the discussion above??

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I haven't done a lot with C++/CLI but coming back from C# to the C++ I learned first it has been interesting to play around with this illegitimate child of C++ and .NET.

See this for question #2, it's quick but it will get you used to some of the terminology so you can search further. Essentially you are telling the system I want a "pointer" but I want you to keep track of it for me.

The answer to #3 is that go with your gut and let the intellisense help. Basically anytime you would be going from a namespace down to a class you need the :: and if the object's a pointer going down into the methods itself you need the -> operator. Some datatypes such as Point in the System:: Drawing, for example, are actually C# structs (which are not generally used with pointers in .NET for some reason) so in referencing the elements of one of those you need the dot operator.

I'm not precisely sure what to do about incrementing the pointer. I know there are ways to do it but they straddle the unmanaged bit. I can't really help you there.

EDIT: I was partly correct, you do need to use the Marshal class but I'm not sure which member. Again, wish I could be more help.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Here is an interesting article how on people keep their banking passwords safe

Mine is "BOSCO" but don't tell anybody.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I actually don't use C::B on a regular basis (I don't have it installed right now). I think the installation is pretty straightforward.

The trick to using it is, it's a project based approach. There should be settings there for starting a new project and then a way to add new or existing source code files to the project you've got open. Then you just build the project. After it builds with no errors, run it (there's probably something that looks like a green play button on the toolbar). There's some decent documentation on the C::B site. Unfortunately in addition to picking up the programming you have to pick up the IDE too. So like I was saying stick with what you have for the time being.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

There's actually quite a bit to that site if you go to the reference section. Normally I don't like sites that bump themselves up but the info there is pretty solid. There are usually little code snippets with the references which are handy to see.

Check something like this out. Skip over the pointer stuff for the time being but it goes into quite a bit of depth.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

See what I wrote on post #23, I think we crossed up. You're not going to get it all at once. Read a few tutorials, peruse a book or two, try to come up with your own examples. You're not going to get it all today or tomorrow. It's a language like any other. It has turns of phrase, tongue twisters and odd puns. :)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

And still try entering text with a space in the middle for lol or rofl or name.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yeah, when you have character arrays you can't compare them with the == which only works for objects of type std::string (you can bite the bullet and look at this unless you think you will get confused).
To do what you want with the char arrays, you need to look at the string portion of the C library http://www.cplusplus.com/reference/clibrary/cstring/ . Specifically look at the strcmp function.

We went over this already. You cannot use == with character arrays.
You have to say if(strcmp(rofl,"nothing") == 0) then the char arrays are equivalent and do that for each of the else if, etc.

Either that or

#include <string>
std::string rofl = "whatever";  //instead of std:: qualifier use "using namespace std;" or better "using std::string;"
if(rofl == "whatever") 
       //do whatever
else if (rofl == "whatnot")
      //do whatever else
else
       //etc.
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Go to (on the left side) Downloads then Binary and get codeblocks-8.02mingw-setup.exe. That package comes with the compiler and debugger along with the IDE.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

No worries.

Yes, VC# runs in its own window. I was asking if you had the version of Dev-C++ with the IDE (the windows). There's the link to Code::Blocks. Take a look at youtr leisure. It would replace the Dev-C++ completely as it includes its own compiler. If what you have is working for you for the time being don't worry about using it yet.
The IDE is a place where you can do your text editing/compiling/and usually debugging all in one spot.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

It's gotta be mileage with a lowercase m. Make sure the variables in the set statements match the case of those in the private: section.

You'll see that once you knock a couple of these errors off the rest may be residual.

Some of us are still learning. It doesn't end. Not a bad thing.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I haven't used DevC++ in a good many years. I thought it had an Integrated Development Environment (IDE). Do you mean that you are running g++ from the command line? Btw, if you are going to stick with the g++ route (which it is an excellent compiler). I would get the Code::Blocks IDE that includes mingw (the port of Gnu Compiler Collection for windows). Dev is kind of outdated and comes with an older version of that same compiler.

All the visual studio express (the free ones) products each run in their own IDE and compile from within that environs. They do also come with command line tools if you want to go that route.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Well, if you're going to spend some time with the language you'll have to immerse yourself in its finer points at some juncture.

In terms of windowing, for C++, you're probably a long way off from doing that properly (beyond the cookbook type approach). Visual Basic is really a whole different animal. While VB.NET and a different variant of C++, C++/CLI (with .NET), do compile to the same Intermediate Language the syntax and style and overall type-safe philosophy is different.
If you want the Winforms type approach and a language more like C++ syntax then I would grab VC# instead.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

All right, breathe now breathe. All small things:

void car::setMileage(float mile) 
{       //no semicolon after the method definition
     mMileage = mile;
     //mMileage must be a private variable, yours is called something else
}

And for the others, variables are case sensitive.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Quit posting this nonsense in every forum. Stick to one posting.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Yeah, when you have character arrays you can't compare them with the == which only works for objects of type std::string (you can bite the bullet and look at this unless you think you will get confused).
To do what you want with the char arrays, you need to look at the string portion of the C library http://www.cplusplus.com/reference/clibrary/cstring/ . Specifically look at the strcmp function.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

P.S. There's some guy on that gidnetwork site named WaltP that wrote those great articles. Good thing he's not related to DaniWeb's own WaltP. That would be an eerie coincidence.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Chars are actually 1 byte integers! Check out this table. If you have a char 'a' (note the single quotes for chars) it's actually stored as (the bits representing) 97. There's lots of great resources on ASCII, Unicode (encompasses a lot more characters, including international alphabets), etc. out there on the net. Just for you own personal interest, no need to learn everything about them before you start.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Anything that's private, forget about using the dot operator with it at all. You're closer:

string carsmake;

	cout << " Please enter Make of car: ";
	cin >> carsmake;  //taking into your temporary
                              // (this presumes a one word car make btw)
	cars.setMake(carsmake); //passes in through your method,
                                 //compiler is happy
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Vmanes is right, but also find a good book or resource online (I know that Schildt's book is available on Microsoft's site for free -- I think you need a login/hotmail to get access to it) or look at the sticky thread at the beginning of this forum.
It's important to follow someone else's framework initially so you can get on the right track. Like any other language, you can pick up a lot in a short period of time but to do anything useful with it you must practice the correct syntax and grammar.
So kudos to you for taking it up only yesterday but be sure to get the fundamentals down early.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

The actual error is in main() in line 34. You have make declared as private in your class so you cannot access it with the dot operator. In the same way as you have a getMake() method, you need a setMake() method to change the private value and act as an "interface" (that word can have other meanings in other situations but I mean it generically) between the outside and your class.

So have a public method void setMake(string inmake) {make = inmake;} EDIT: nice vmanes :)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Don't forget that choice == "yes" doesn't work for char arrays (or any type of strings in C for that matter).

Yes, something along those lines will do just fine. Except make j part of your while loop condition too while(strcmp(choice,"yes") == 0 && j <10) and increment j.

But, Instead of the for loop, get one name and number then prompt for more. So wrap up your prompting for one name, number pair in that do/while loop.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You're having it ask for 10 names in a row before a number. You could combine your for loops into one and take in name[0], number[0], name[1], number[1] etc. or do it in a while loop that asks if you want to keep entering more names and numbers each cycle.

Also, you've still got some scanfs in there. You should ideally transition all of those into fgets.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Regardless, the general philosophy of this board is "we only give homework help to those who show effort" (meaning that the poster themselves should show the effort and receive help in proportion to their input).
Rather than writing the solution on your local machine and guiding this poster through it step by step you have handed him/her something that he/she could conceivably hand in for a grade. Trust me, darn near any experienced person could have done what you did for her and we didn't. There's a reason for that. The fact that you wanted to do it a second time after folks had expressed displeasure about it is kind of insulting.

Using your argument, I should never try to mix the colors myself because there is no value in that learning process. In doing so, again and again, you'll have to zip me through all the stages to get to the final product and then we can compare colors. I may know what the color looks like but I cannot get there on my own.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

you absolutely need one, because of ( matrix (*this) )

Parsing error in my brain in regards to my last post there. I got it now. Apologies.

I had implemented == and != (I had thought they were inline in the header) so I hadn't run into that but it's true that as it were they were non-existent.

Another observation: I'm thinking that += should use + operator, not the other way around.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Perhaps you did not get the message up there but please do NOT give the OP a full set of code. Help him or her through it but don't give the whole thing. This doesn't help him or her learn a thing.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Why do you have "matrix" on line 79 of your implementation file? Were you trying to cast *this? There's no need to do so. I'm getting responses without crashing, but check they are the right ones.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

cin>>array[i]; remember that '\n' (like when you hit enter) is a character too. Look into using cin.getline() for this purpose to get the entire line of digits (up to the size of your char array).
-or-
Look into using getline(cin, ) with a std::string and you can avoid the size limitation.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Hint, don't take the digits in as numbers. Hold them in a char array or a string. Otherwise you can't hold spaces in an int array anyway.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Sorry, it was a stringstream ss; so include <sstream>

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Except that the length of name[j] is 10, but everything else seems to be ok.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

but this is not working properly

That's ok because he/she probably shouldn't have given the whole thing away. Think about how else you might store a group of digits...

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Make an int array that has 10 elements (so you have one for each digit). Up the count in that "bin" when you encounter a particular digit. Output your array.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

My first thought would have been to use a stringstream and substrings, but this is more complicated. You need to use string.find() and it's variants to get all the operations in your sentences and break them down using the rules of precedence.

Otherwise if you are just looking to do this for the 3/2 portion you could do something like this:

(after isolating from the + and * signs)
index = input.find("/");
float three;
	if (index !=string::npos)
	{
		ss<<input.substr(0,index);
		ss>>one;
		ss.clear();
		ss<<input.substr(index+1);
		ss>>two;
	
		three = one/two;
	}
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Can you give us an example of what a typical part_ would look like? Is it just like "400.0/20.0"?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Can you clarify with an example? Are you talking about something declared as public within a class? You can certainly use the . operator: (in main you declare) myclass myobject; myobject.mypublicvar = 10; Something like that?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Can you post your header up? I can recreate most of it but it's time consuming to do so. More than likely you have an exception that is sneaking past your catch statements but I am not certain of that.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

See below:

Ok, I changed this in my source code :

#include <cstdio>
#include <cstring>
int main ()
{
	char name[10][10], temporary_name[10];
	char option[6];
	__int64 number[10];

Just make this a char number[10][10]; since you're not doing any computations with the digits anyway

int i,j,k;
	char quit[10];
	do	{
		printf ("This is a telephone directory.\n");
		printf ("What do you want to do?\n");
		printf ("Typ 'enter' to enter a number, typ 'view' to view a number.\n");
		scanf ("%s\n", &option);
		if	(stramp (option, "enter") == 0)	{

Typo on strcmp.
For scanf, just use fgets all around, for example fgets(option,sizeof(option),stdin)

printf ("What is the name of the person?\n");
			for (j = 0; j < 10; j++)	{
			fgets (name[j]);

Not the right syntax for fgets, but better approach!

}
			printf ("What is the number of the person?\n");
			for (k = 0; k <10; k++)	{
			scanf ("%I64d", &number[k]);   //see above
			}
			printf ("Person stored in memory.\n");
		}	
		else	{
			printf ("Enter the name of the person.\n");
			fgets (temporary_name);  //syntax
			for (i = 0; i < 10; i++)	{
				if (strcmp (name[i],temporary_name) != 0)	{
					printf ("%I64d\n", number[i]);
				}
			}
		}
		printf ("What do you want to do now?\n");
		printf ("Typ continue if you want to go to the menu, typ exit to exit.\n");
		scanf ("%s", &quit);  //again fgets
	}	while (quit != "exit");
	return 0;
}
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You don't have to do any casting. Go element by element. If it's '1' (ASCII 49) how would you recover 1 from 49? How would you recover 2 from 50? Subtract 48, which is '0'.

char a = '4';
int x = a - '0'; // since chars are really ints

I had meant that code snippet as more of a demonstration than something to actually incorporate directly. Remember I had said take into a char array and transfer to an int array.

WaltP speaks the truth, write down your objectives and then try to accomplish them on paper. Write out a number with spaces and "be the computer," read along and get the information you need and put it someplace else. It will save you time in the long run.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You don't have to do any casting. Go element by element. If it's '1' (ASCII 49) how would you recover 1 from 49? How would you recover 2 from 50? Subtract 48, which is '0'.

char a = '4';
int x = a - '0'; // since chars are really ints
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You don't even have to go that far. Do it a char at a time. Hint: the ASCII code for '0' is 48 and the ASCII code for '9' is 57.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I think he meant it as: fgets(a, sizeof(a), stdin ); (but just code your array size as the second parameter).

Yes, fgets can be used for file streams but in this case you are specifying stdin (generally keyboard unless set otherwise) as the stream.

A hint: you should take the data in to a char array and transfer it to an int array.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Well, take a step back and ask what are some examples of imperative and critical applications.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Well what are some of the characteristics of imperative and critical applications? (specifically their hardware)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What are some of your ideas? I don't want to spoil your fun.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you are writing a C++ program why are you only using the C libraries?

See this about gets(). It may not solve all the problems with your code but it will be a step in the right direction. Use something like fgets for all your char array inputs.

Nick Evan commented: Moved to C +12
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

scanf("%c", &a); is not correct. Try using fgets() instead. After getting your number string, immediately print it out to make sure it's ok before moving on to process it. printf("%s", c); would not be correct either, you are trying to print out an int as a string.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You only have 4 calls to your helper function in your case 5, btw.

From what it looks like, you're basically setting x = 0, (since (0 + 0)/2), y = 0 (from (0-0)/2 )and those values are never changing as you pass them in with the different abscissas. So why not just call all those methods with x = 0,y= 0. I'm not sure the way that you have it is exactly what you want.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Where are a2 and b2 supposed to come from? You attempt to write to them below those equations in case 1 but they are never declared anywhere (not even in your global scope -- which is good that you didn't, but then they'd be somewhere!).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Ah, gotcha. Depending on certain (generational) constants and other run-time data, Gallagher without a designator usually refers to the standup comedian. http://en.wikipedia.org/wiki/Gallagher_%28comedian%29 (careful there's spoilers to WaltP's question there). :D