jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

giving a vertex on a 2D plane

What information do you have about the plane? (equations, points, etc?)

This does a nice job of explaining things.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I am not for sure if addresses.push_back(ads);, in the code below, will make the above possible.

Can you clarify what you mean by this? Your code is confusing because you have ads.push_back(name); and then addresses.push_back(names); . Did you mean names instead of ads in the first part?

It seems like what you are doing is essentially correct. Have you tried printing out the 2D vector and seeing what the results are?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Increment i on line 16 instead of count, eliminate line 30, and use another while loop (or a for loop since you know the count) to display the items.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Make a list for yourself of precisely what is confusing about those topics, for example

Typecasting:  Is it necessary to cast my variable when I am doing XYZ
Twos compliment:  How do I handle negative numbers

etc.
Now you have a list of things you can search other sites for, like you can Google "C++ typecasting XYZ" or "2's compliment negative numbers". I know people on this site would be more than happy to help you with specific questions about specific areas, but you've got to figure out what those are.

Fbody commented: Very true, And good advice.. +5
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Part of the problem is you should wait until all of the value are read in, and then sort them. You're sorting the empty spots in your array around and potentially overwriting them with the next input.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

index <= 5 Your array is only 5 elements long, you should go up to <5 only (0,1,2,3,4)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

On line 80+, when you're swapping the agent array, swap the other arrays at the same time. If you're swapping elements 8 and 9 of agent[], swap 8 and 9 of sales also. "i" will give you the index either way. To declutter the code in that region, see if you can come up with a swap function.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

how am I doing?

You're attempting to return the results now, but to what? To the operating system? That's where the return value from main() goes.

This is one of those times where you're going to have to sit down and do it with pencil and paper and turn it into code afterwards. Read exactly what the instructions are telling you, and write it out.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You need a loop. The way your function is situated now, you call it by passing in the array without knowing how many members it has,which doesn't actually matter because you're printing out the first element, incrementing i and then returning. "i" is not maintained between calls, so you're starting at zero each time.

But there's another problem, when you're reading in your data points in main, "i",(which is not connected to the "i" in the display function in any way) is not changing at all, so you're writing each subsequent read from on top of the first elements of each array over and over.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

i have the "HEY" stored as an "string command" and the number stored under as a op1 array

I'm really not sure what you're trying to say there, but it only makes sense in the context of your program. Please post your code.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Check my answer to question!

That comes across as very rude.

Use braces to tell you which ifs and elses match up (when the if statement only has one line of code following it, you technically don't need them, but it should help you see where your errors are)

if(something)
{ 
   if(something)
   {

    }
}
else
{


}

etc.

The statements a*7 and b*10 don't do anything by themselves. You may want to reread your text to see some examples where something is assigned to another variable.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Sure, someone will be glad to help, but please make some attempt at those two functions. No one is going to write it for you. I know you said you "messed up," but that's what we need to see to get you going in the right direction.

Start with the input function, that shouldn't be anything you haven't seen before, step through the array with a loop and prompt the user to input all of the fields.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

i guess sort n unique cannot be used for vectors.....

Did you look them up? They certainly can.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Hope its not a homework>>>

Homework questions are fine as long as the poster has shown effort.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I have no idea what might be wrong with your code, to be honest.

Try looking into http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx the Process class. I think you'll find there's quite a bit there that will help you, and you won't have to mix the managed and unmanaged code as much.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What does it mean that they don't look quite right? Are you calling SetPrice and SetTitle one after the other and it's skipping over your SetTitle input?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Thanks.

Otherwise, he will have to play a little game of #defining and #undefining the keyword around every use of it.

Yes, that would be painful.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You're welcome.

i mean we cant use another language , right

Forum posts must be in English, yes.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

thank you so much

but

int shop :: getshopitem (){
 
for (int i = 0 ; i<10 ; i++){
return shopitem [i]
}
}

semicolon maybe after

return shopitem [i] ;

!!
but why would it return one value it's inside the for loop , should i return it with function call ?
it will return an object from function item with specific index , we still didn't take operator overloading , but i will look for more information about it from Google ...
^___^

Yes, you definitely need one after return shopitem[i] . In the image that you posted, you had an extra semicolon after the for loop. Remember that without braces, the for loop will only execute the next statement. Think of it being like:

for (int i = 0;i<10;i++);
   std::cout<<"Does this get executed 10 times?"<<std::endl;

is like saying

for (int i = 0;i<10;i++)
  ;
std::cout<<"Does this get executed 10 times?"<<std::endl;

//it only gets executed once either time

For that particular method, you're probably better off doing something like:

int shop :: getshopitem (int i){
 
  return shopitem [i]; //you could check that the index is valid, too.
}

because the first time through that loop, the code would return and then that's the end of the method call.

If you haven't done operator overloading, just read in strings and use your "setter" method to set the store name.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Depending on what you are actually going to do with the .NET code, you can relax the compilation from /CLR:pure setting to just /CLR (within the project propeties) and see if the two will play along.

The unmanaged code is not called CLR, by the way. The CLR is the runtime for the managed code. I'd probably call the first part Win32 API and/or native code.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Have a look at this thread http://cboard.cprogramming.com/windows-programming/43203-disable-console-scrollbar.html (also, there is a link to a tutorial on this subject highlighted in red). I'm afraid I don't have enough experience with this kind of thing.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Did you download the source? http://www.qtforum.org/article/29890/qt-4-6-linking-problem.html would indicate that there may not be a debug build present. Please give some more information as to your compiler, etc.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What are you trying to do? Maybe that will help in showing you a different way.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Please don't post your questions on multiple sites at the same time. You'll end up wasting the time of people on one or the other.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

mall.cpp

errors

[IMG]http://i55.tinypic.com/34i47ib.png[/IMG]

For the first error, you don't have to specify the datatype when you are reading in. What you need to do for the first one, is overload the >> operator of your shop class. As it stands, you're trying to input the name of the shop, but the class has to know which variable you want to store it in, it cannot guess.

You can either modify your class to have an overloaded >> operator (see http://www.java2s.com/Tutorial/Cpp/0200__Operator-Overloading/ostreamandistreamoperatorforaclass.htm, ignore their egregious <iostream.h> at the top and all the other info is good), or you can read in the shop names as strings via cin and use your setshopName to take those strings and write them into your objects.

shop.cpp

[IMG]http://i54.tinypic.com/11c59oi.png[/IMG]

just those 2 have errors

The first one, what you are trying to pass in is the element that's one past the end of the array (which doesn't exist).

int arr[30]; //ok, need to specify the length when declaring

int temp = arr[30]; //no, indexes run from 0 to 29 in this array
int temp2 = arr[29]; //okay, we're assigning one integer to another

Just pass in SI, not SI[10] for the top error

For the second error on that page, you don't need the datatype again, just like you didn't on the other page.

Re-read your getshopitem method too, there's a typo that's going to stop your for loop from doing anything, but even after you …

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Anyways, if you really have to use it, you can undefine the define after including the other library.

I had thought about that too, but what if some of the functions in the code depend on that symbol? Does it not matter by that point?

(sorry @OP to inject a couple of my own questions here, but since we're talking about it...)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Okay, we're getting closer, but you need to point out where the errors are. It is not my responsibility to compile your program and interpret the errors.

i didn't get what i want ...

He/she probably didn't want to do it for you, either.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You've got a parenthesis in the wrong place. The very last one doesn't belong (and you don't need the pair around temp == '%' If you're in this kind of situation, start with one thing:

if(yada == '%')
and compile, then add
if(yada == '%' || yada == '.')
compile again
if(yada == '%' || yada == '.' || yada == ';')
etc.

It seems like it will take longer, but you'll be able to keep track of all of the parentheses.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Sure, make me open the darn program. Just kidding.

This is what I was trying to remember in the last post:

Go to Project
<Your Projname>Properties
Configuration Properties
Linker
General
Additional Library Directories -- add them in (where are the lib files? - can be more than one directory

Then, still under Linker

Input
Additional Dependencies -- add in "mylibrary.lib, mylibrary2.lib"

I'm assuming you already put in your include directories under

Configuration Properties
C/C++
General
Additional Include Directories.
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

That's a linker error, actually. Have you pointed VC++ to the right library directory and listed out the .lib files you want it to link to? (all this under Project/Properties/CC++/Linker (inputs and general)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Characters in a string can be accessed by array notation:

std::string str = "apple";
std::cout<<str[0]<<std::endl;   //a
std::cout<<str[1]<<std::endl;   //p

So go through your string with a for loop, do your testing of each character with your if statement. If they are all alphabet characters, then don't reprompt the user, but if even one of them isn't, go back through and reporompt them:

bool allalpha;
while(!allalpha)
{
   for (over the characters)
   {
       if(character is among 'a' to 'z' or 'A' to 'Z')
            allalpha = true;
       else
       {    allalpha = false;
            break; //out of the for loop  
       }
   }
}
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I'm not sure if this will work, but try referring to the global one as ::thread and the Boost one as Boost::thread .

Edit: no, the more I think of it, the even less I think that will do it because the global one is a define, you're not really calling it anywhere. Sorry, wish I could have been more help. I was thinking about reordering the header files, but I think that might only be a patch fix. Doubtless you probably googled about combining this library with boost, but someone has to have encountered this before.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

You're on to the right idea. You can use the if statements that you already have (with some modifications) or you can use the functions found in <cctype> (isalpha(), etc.)

Looking at your second to last blue code block, you can see that you can't compare a character to a string, but you can loop through the characters of the string (using a for loop) and check each character.

For your last code box, you need to indicate that the elements you are comparing against are characters. You also can't just chain along your || statements unless you do:

if(oid[count3] == '%' || oid[count3] =='^'|| oid[count3] == '*')  etc.

of course you could put oid[count3] into a temporary character and compare against that to save you typing.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

do private messages on programs get answered?

No, someone may send you a polite refusal, but it is against the site's policies to give or receive help via private message.

If you have concerns about posting your code, see if you can whittle it down to just the point where you are having the problem and post that section. I don't think anyone would fault you for that, but only you know your institution's policies.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
if (file == "Forces1" || "forces1")

must be

if(file == "Forces1" || file == "forces1")

otherwise, in the first instance it's evaluating "forces1" as true since it is not null, so your statement's always true.

Same thing for the else if condition, too.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

What does your question have to do with the subject of the thread?

Have you tried searching on Google? There are at least a few pages particular to C++ flowcharts, but as far as I can remember, the process is pretty much language agnostic.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Duplicate words? Duplicate letters? Duplicity?

What have you done on this so far? Are you allowed to use methods from the standard library (e.g., std::sort, and std::unique)?

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster
if (yn == "yes" || "y" || "yeah" || "yep")

doesn't work, it must be

if(yn=="yes" ||yn=="y"||yn=="yeah"||yn=="yep")

On line 32, you're not using the return value of quant anyway, but to return more than one thing from a function, use references:

//sending in 2 references
void myfunc(int & a,int & b) //or you can return one the "old fashioned way" and send the other in by reference
{
   a++;  //modifying the actual value of what we're passin in as "a" in here.
   b+=3;
}

int main()
{ 
   int x = 4;
   int y = 5;
   myfunc(x,y);
   cout<<x<<endl; //5
   cout<<y<<endl; //8
}
jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

i have to do my homework ....

Yes, that is the key here. You've posted your assignment, but what have you done with it so far? Try to code as much of it as you can, and post back with specific problems. There's no need to put everything in bold my eyesight is still good.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

I get quite a few compilation errors with your code about your use of the methods in algorithm. As an aside, check out http://www.daniweb.com/software-development/cpp/threads/262894 for Narue's solution to the problem with using toupper in this context.

Edit: you didn't include <limits> for the cin.ignore call

vector<string> words;
const string THE_WORD = words[0];

What is words[0] equal to when you are trying to assign it? There is nothing in words, it's only been declared. Even if it were valid, there's really no need to have these variables global anyway, I'm not sure why you did that.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Can you read in a text file?

Can you count the number of words in a string?

Start by gathering some of the pieces that you can do together, and try to integrate them into one whole program.

coz im only 1st yr college student

All the more reason for you to take responsibility for completing your assignment.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Please post your attempt at this problem.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Grab #7 (it's free and legal) from http://www.qtrac.eu/marksummerfield.html. #6 is the current edition, but I don't know how much that is.

The book takes you through making a rudimentary spreadsheet within the first few chapters.

It also goes on to talk about the other aspects of the library like the abstract data types, sockets class, database connectivity, etc.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

If you indented and spaced your code properly like

if(etc)
{
   //code indented here
}

else if (etc)
{
   //code indented here
   if(etc)
   { 
       //code indented here
   }
}

else 
{

}

you'd probably notice it right away. Try that and see if you can find it and post back.

Also, your thread is no more urgent than anyone else's. Pleas of "urgent" in a thread title tend to get the thread ignored.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

Okay, I'm all done with it. What now?

What have you tried at this point? Please post your efforts.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

it's my experience that they tend not to be scientists/engineers/programmers.

I think you can say that is true in a majority of cases, but I've known a handful of people that put sort of an "artistic" spin on technical jobs, and they tend to be good "big picture" type thinkers.

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

One way would be to go through the string and replace the ':' with a ' ' (either in a for loop, or through something like the .replace() method of the string.

Edit: Vijayan has a good way ^^^^^^^^^ (I was thinking along those lines but was trying other rhings, oh well).

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

U sir need an award!

I accept all large financial donations, which I will, of course, pass on to charity ;)

jonsca 1,059 Quantitative Phrenologist Team Colleague Featured Poster

See this thread on Stack. It's using C#, but you should be able to translate the syntax readily.

Like I had said in the other thread, it takes a little wizardry to update the GUI from another thread (which is basically what the backgroundworker is).

I have never actually implemented this (I've used backgroundworker for different tasks), and I definitely don't know how to handle it with raw API calls.

Pay close attention to the answer with the green check (and the associated comments), as I think that gives more or less what you need.