siddhant3s 1,429 Practically a Posting Shark

>>I'm currently using the new borland so this is a correct syntax after all it's
>>working on my computer, as for the variables i am on writing description for
>>everyone of them.
This is a wakeup bell for all those who are using Old compilers ( like the OP is using Borland's) that C++ has been standardized 13years ago. So there is no concept as "It is working on my implementation so it ought to be right".
This is what cooks me up boiling. Ruthless.
To the OP, Please Read :http://cppdb.blogspot.com/2008/10/why-you-shouldnt-use-you-use-old-c.html
and http://cppdb.blogspot.com/2009/02/should-i-use-void-main-or-int-main-or.html

These are some link is from Bjarne Stroustup's homepage:
* A Very simple ISO standard program http://www.research.att.com/~bs/bs_faq2.html#simple-program
* About void main http://www.research.att.com/~bs/bs_faq2.html#void-main
and
* This ones about naming variables http://www.research.att.com/~bs/bs_faq2.html#Hungarian

(I am really surprised by the guts of OP. A good man (Mosiac) is giving him advice and he is just too much a snob to accept it)

Salem commented: Fantastic!!!!!! +30
siddhant3s 1,429 Practically a Posting Shark

A prime number is a number which when divided by every integer greater than one and less than itself, will never leave the remainder zero.
Now check out your for loop. Is this what your for-loop checks? No.

So, re frame your for-loop.

siddhant3s 1,429 Practically a Posting Shark

For the first one Read:http://www.research.att.com/~bs/bs_faq2.html#constraints


Arrays do not have variable size.
Use vectors of vectors. Define your struct as :

struct graph2D {
 int id;
std::vector< std::vector<bool> >matrix ; //there is a space between > >
}

This way you would never need to initialize it's size. If you then too want to, use vector::reserve() function to initialize some space.

siddhant3s 1,429 Practically a Posting Shark
siddhant3s 1,429 Practically a Posting Shark

>>It's not the best method to learn language: waste a time in asking help on
>>forums instead of read elementary textbook on a very basic language concept.
Absolutely.

To OP: You have declared a integer variable called inches and not an array.
Another point is : Always initialize your variables before you use them.

Also, It is better to use the code tag as :
[code=cpp] //Your code goes here

[/code]

siddhant3s 1,429 Practically a Posting Shark

Your problem is with the way you're compiling your program.
In g++, compile your code as : g++ -o OUTPUT.EXE SingletonMain.C Singleton.cpp This is not an compiler error but a linker error. Your linker do not have access to Singleton.cpp hence he doesn't have definition of Singleton<T>::instance() hence the error.

siddhant3s 1,429 Practically a Posting Shark

>>My compiler is also saying that with a virtual function I need a virtual destructor,
>>how do I right that?
LOL, I just wished my compiler was that smart.

siddhant3s 1,429 Practically a Posting Shark

>>Dear NathanOliver, your code is working perfectly after changing..............
It may be working on your implementation but the code is in a state of undefined behavior.

>>Edit:: Some additional information on if (test != input) as 'input' is a double
>>and 'test' is an integer, 'test' will be implicitly converted to a double to do
>>comparison
This can't get worst. When you know he is doing a float comparison, there is a lot more need to warn him than smiling.
To OP and everyone : Never use float comparison in your programs. It will lead to undefined behavior.
You may want to like to read: http://www.parashift.com/c++-faq-lite/newbie.html#faq-29.17

tux4life commented: Very interesting :) !!! +3
siddhant3s 1,429 Practically a Posting Shark

>>Im using my colleges "dos style" environment to program in and it does not let me
>>copy and paste outside of that program
You mean something like Turbo C++? Well, every compiler stores the while somewhere or the other. You you can definitely copy-paste the code if you are able to find where those files are stored.

I think you should be switching to a new compiler: http://cppdb.blogspot.com/2008/10/why-you-shouldnt-use-you-use-old-c.html

Well regarding the problem in hand, you've already got the solution above. A slight advice which I would like to give if you respect that:
1. Rather than defining then assigning, define and initialize variables: As in Line 5 you define the highTemp and then on line 7 you assign value zero to it. Better thing to do would be to initialize highTemp on line 5 itself:

int highTemp=0;

Same mistake has been repeated on line 4 and 8 for the variable x. You should have been initializing it on line 4 itself.
2.Another thing to note is that among all the temperatures in the array, there will be at least one highest temperature. So rather than initilizeing highTemp to zero, you should have been initilized it with the first element of the array

int highTemp=YrTemp[0][0];
    for(x = 1; x < 12; x++) //not that I am starting the counter from 1
     {
        if(highTemp >= YrTemp[x][0])
           {
                      highTemp = YrTemp[x][0];
                      highIndex = x;
           }
     }

Affect of these two things would be …

siddhant3s 1,429 Practically a Posting Shark

curl can handle HTTP GET and HTTP POST
It also support FTP
So if this is all you want to do, I suggest go with cURL. Its more generic than anything.

>>But once i'm startet on network related programming (whats the right term?)
>>i would like to be able to do more than that i guess, so i would rather not do
>>to many shortcuts
Yeah, then move to Asio

siddhant3s 1,429 Practically a Posting Shark

>>actually i wrote it myself... your negative and untrue comments are not any help
>>at all...
They are actually helpful. These comments might not solve this problem, but it will help you in long run.
Copying the code which you don't understand is not expected from a good programmer. There is however one exception to this : Libraries. When you use libraries (like iostream or string) you are actually copying the code but that is perfectly desirable since you are not expected to know what is going behind the scene.

You said that your friend helped you build this code. Here 'helped' simply does not have any meaning. It may be that he actually wrote the whole code !!.
You should perhaps try to find that friend and ask him how this thing works.

Here on Daniweb, we stricktly are against 'code wanters' (like you) and 'code givers' ( like vsha).

Read :
http://www.daniweb.com/forums/announcement8-2.html
http://www.daniweb.com/forums/thread78223.html

Also note that your current program is very trivial for most of the programmers here. So if you think by any means that we don't have enough knowledge to solve this, you're wrong. We are helping you ( by criticizing ) and sooner or later you would find that this is a big help.
Ancient Dragon has already guide you enough on post #2. If you cannot follow his advice, perhaps you should read your textbook thoroughly.

siddhant3s 1,429 Practically a Posting Shark

>>You absolutely dont need winsock to get infos from a web site (!)
The OP says "for stuff like, obtaining info from a website? "
He surely wants to do more rather than just getting info from a website.
To the OP: If you really need to get some info on a website, you can use curl Free and cross-platform

siddhant3s 1,429 Practically a Posting Shark

>>I looked it up in two different books (*) about C++ programming and they're
>>using exactly the same technique to write a structure/object to a file ...

Yeah because it is the standard technique. I am not against it. I too use it.
It would cause hardly any harm except in the case I mentioned.

siddhant3s 1,429 Practically a Posting Shark

Does anyone know how to write a simple crading system in C++ programming???

Yes I know

tux4life commented: LOL :P Straight and to the point :) +3
siddhant3s 1,429 Practically a Posting Shark

#include <string> should be
#include <cstring>

siddhant3s 1,429 Practically a Posting Shark

Why not just use isalpha?

[edit] Sorry I didn't saw ahlamjsf's solution.
It was so that I had been amazed (shocked) by looking already posted pathetic codes above.

siddhant3s 1,429 Practically a Posting Shark

>>would you recommend learning python, and then running the python programs trough c++ (seems clumsy)
No, I don't

>>or using one of the libs you mentioned?
>>any change you know where to find a good tut on the 2 libs?
This is much better. Use the winsock if you intent to write only for windows.

>>It seams to be hard, finding the way around the boost asio header files.
>>Or is it just me?
No, it is not just you. It is a hard fact that Boosts documentations are very breif and true to point. You have to help yourself if your using Asio

Bladtman242 commented: Thank you for your answers, they are very helpfull +1
siddhant3s 1,429 Practically a Posting Shark

>>Nice explanation but I think it doesn't make sense if you're just writing/reading this struct to/from a file using the method I provided ...
Yeah oh well. This will only create a problem when suppose you wrote a file in PC1(with the program you posted, compiled on PC1 itself) then took that file on PC2 and reading(with the same program compiled in PC2). The sizeof() will yield two different values on PC1 and PC2

siddhant3s 1,429 Practically a Posting Shark

>>An example of this would be to measure the amount of electrical energy in
>>the air at any given point using some sort of analog device, which then
>>converts this into a voltage difference, which is then converted to a digital
>>value (usually between 0 and 4096) to represent the voltage in the air, within
>> a given limit.
Thanks for enlighting our minds. But could do tell how will you implement this 'magical' apparatus.

>>See this is the awnser I was looking for THANK YOU +rep but how do i do this ?
Wow, were you?
Ask him. I am no magician.
I doubt if you need that extreme randomness.

>>Umm...What point was made, exactly, with that post?
The same point which you made by yours. He just increased the randomness by a million times.

siddhant3s 1,429 Practically a Posting Shark

Here is a script that does this :http://www.blackhillsoftware.com/blog/2006/06/26/using-innosetup-with-the-dotnet-framework/
As you know, Inno Setup have its own scripting language .iss
So you may download the script from here and use it.

I have not read the article myself though.

siddhant3s 1,429 Practically a Posting Shark

Inno Setup is a free installer for Windows programs. I used it my several projects wherein I needed to port my Linux Application to Windows user ( windows user really like this setup.exe)

You will be amazed by its simplicity and power.

siddhant3s 1,429 Practically a Posting Shark

Python has a great support of internet.
If you want it do it C++, things can go messy.
If you are to only develop apps for MS Windows, they have winsock library. Use it.
For cross-platform support Boost's Asio is a good one.
Best of luck

siddhant3s 1,429 Practically a Posting Shark

Both of your questions (even the former one) are related to the OS rather than C++.
I am not a windows user (I use Linux). Then too, from what I know, I can tell you that:
Problem 1.Most of windows developers store the application data in C:\Documents and Setings\Application Data\your_application_folder Problem 2. I am afraid you cannot. But you sure can use a binary file instead and encrypt it using some sought of complex algorithm.

siddhant3s 1,429 Practically a Posting Shark

Quotes from The C++ Programming Language (Bjarne Stroustup)

The size of an object of a structure type is not necessarily the sum of the sizes of its members.
This is because many machines require objects of certain types to be allocated on architecture-
dependent boundaries or handle such objects much more efficiently if they are. For example, inte-
gers are often allocated on word boundaries. On such machines, objects are said to have to be
aligned properly. This leads to ‘‘holes’’ in the structures.

siddhant3s 1,429 Practically a Posting Shark

You perhaps should enable the "View Hidden files" option from the folder option of the windows explorer.

siddhant3s 1,429 Practically a Posting Shark

MatEpp>>The names, wheel, brand, etc. are missing from
[edit]This was posted in the post above. But Maybe he realised his fault and then removed this remark marking it as "Bad Post"[/edit]
That is a prototype of the constructor. It is perfectly fine.
It just tells the compiler that " you will find the definition of the constructor somewhere in the code below".
You usually omit the name of the formal parameters when declaring prototype.

siddhant3s 1,429 Practically a Posting Shark

Try this:

class Bike {
public:
    Bike (const int, const string, string, double);
private:
    const int w;
    const string b;
    string c;
    double ws;
};
Bike::Bike(const int wheel, const string brand, string color, double wheelsize):
w(wheel),
b(brand),
c(color),
ws(wheelsize)
{}

It is generally better to write constructor using member initialization(what I did) rather than assignment(what you did).
This approach is more efficient.
why? because in this approach you are saving the overhead to create wheel,brand,color,wheelsize. Instead you are just using those value just to initialize your data members

siddhant3s 1,429 Practically a Posting Shark

Yes. and No
Yes because it is really broken.
No because it is practically not broken.
I agree with Tux in this regard.
Comparing to the simplicity, the hashing solution will be more practical.
Else, do you have any good solution jephthah?

siddhant3s 1,429 Practically a Posting Shark

>>not true. MD5 is broken.
This is true that MD5 has been broken. I heard this news long before.
I said he could use some hashing algorithm, not necessarily MD5. But the point in giving example as MD5 was that it is very famous.

siddhant3s 1,429 Practically a Posting Shark

>>Isn't that because cout is overloaded for pointers ?
cout(strictly speaking, the operator << is overloaded, not cout) is overloaded for pointer to char and assume it to be a cstring i.e. character array which are null terminated.
consider this:

char c[6]= "Hello";
int *d[5]={5,2,1,4,5};
std::cout<<c;//prints Hello
std::cout<<d;//prints the address of d[1]
siddhant3s 1,429 Practically a Posting Shark

&p[2] is same as &(*(p+2)) which is same as p+2
So cout<<p+2 will print the array which has the the first element as the 3rd element of p. Hence the output is "ndon"

p[11] means *(p+11) that means "tell me the value of the 11th location from p" (remember p is a pointer)

siddhant3s 1,429 Practically a Posting Shark

>>Siddhant(a) in sanskrit means Theory.
Umm.... Since it my name. I have right to correct you. The perfect translation of 'siddhant' is 'principles'

>>redirect my c++ questions to you from now on.
You should perhaps start thread on the C++ forum where everyone can see your c++ problem. I am there most of the time. I would extend my help as far as possible.
>> It is good to know you are good at it.
I never told you.

siddhant3s 1,429 Practically a Posting Shark

(Being very gently) It is siddhant3s
>>rather unix programming tools sucks.
Do you mean that you are not comfortable with shell?
So you want everything in GUI?
I don't see much in the point-and-click methodology of GUI systems. I rather would throw my mouse.
But again, it depends on personal taste.
C++ is of course a great language( you can say I am biased) .
But using C++ to write OSs( As one of your post mentioned) is certainly not a great idea ( this is what annoyed Linus)

>>I cant stop questioning why universe exists rather than being nothing.
That's a good habit. But tell me, isn't it unusual asking those things from humans whose answers are still unknown to humans. I would rather try to find out my self.

Your hate for Unix is reflected. But its such a sorry state for you that you want to discuss those things in which we can't help you.
You are doing great job by casting yourself to Unix.
Even if you don't like Unix, try to like it. You may want to go to a hypnotist so that your Unix-o-phobia is removed.

siddhant3s 1,429 Practically a Posting Shark

I guess I can say yes.
If this won't hurt you:

char* arr="The Old String";
int old_len=strlen(arr);
char *old_ptr=arr;
arr=new char[old_len+1];
strcpy(arr,old_ptr);
strcat(arr, "X");
std::cout<<arr;//prints The Old StringX
//.
//.
//.
//after you used arr
delete[] arr;

Basically, I created another dynamic array and added a character.
[dit] I think it is obvious that you will have to #include <cstring>

siddhant3s 1,429 Practically a Posting Shark

>>in php we can append string, how could I do this in C++:
You could if you were using strings in C++. But the very fact is that you are not using strings but c-strings here.

#include<iostream>
#include<string>
int main()
{
   std::string arr="Foo Bar";
   std::cout<<arr; //prints Foo Bar
   arr+="X";
   std::cout<<arr;//prints Foo BarX
}
siddhant3s 1,429 Practically a Posting Shark

>>what does it have to do with being powerless sidarta
Its siddhant3s.
By the time I was posting my last comment, you have already posted the one above mine.

So your company uses Unix, and thus you're helpless to use the 'dirty' Unix.
I feel very sorry for you.

So, what are you intending with this (useless) thread?

I suggest you something, go to your Boss and give him a free copy of this book.
Lets see what happens!

siddhant3s 1,429 Practically a Posting Shark

>>I don't like Unix but I have to like it ...
This shows you are power-less.
Why don't you read some OS development books and start developing your own OS ( better than Unix) rather than pulling this thread which wont lead you anywhere?

siddhant3s 1,429 Practically a Posting Shark

There are several option when you write functions that return multiple values:
1. Using references: You could have few parameters that will be passed as references and use them to store the output

void split_decimal(double input, int& integer_part, double& fraction_part)
{
   integer_part=static_cast<int>(input);//convert input to integer
                                                                    // and store in integer_part
   fraction_part=input-integer_part;
}
//usage:
double val=1.254;
double frac;
int integer;
split_decimal(val,integer,frac);
//now integer=1 and frac=0.254

2.To return an array (or vector): if all the output values are of same type, you may return a array of all those values. But I do not suggest this method as it is clumsy.

siddhant3s 1,429 Practically a Posting Shark

I have read the book.
And let me tell you it was not more to just fill my daily humor.
It has some good joke-like interaction with the shell of *nix. Like this :

$make love
Do not know how to make 'love'
$sleep with me
bad character

There are lot more examples. The author is pointing on the behaviour of Unix shell that it doesn't check for typos.

But just tell me:-> if Unix is bad, what are the options? Pleas don't utter "Windows" because I have seen more ridiculous bugs in windows. Besides, windows are OS for 'normal' humans.

siddhant3s 1,429 Practically a Posting Shark

What is the error message?

chg = RATE606;
     else if 
     loc = (zip.find("605", 0));
     (loc >= 0);

else if requires a condition. The proper code would have been

void calcShippingCharge(string zip, int RATE605, int RATE606, int &chg)
{
     //search zip code for proper prefix
     if (zip.find("606", 0) != string::npos)
           chg = RATE606;
     else if (zip.find("605", 0) != string::npos)
          chg = RATE605;
     else
          cout << "Invalid entry, please try again" << endl;

}

You should have a look at http://www.cplusplus.com/reference/string/string/find/

siddhant3s 1,429 Practically a Posting Shark

Not very readable.
Here is the fix of the code you posted before the last one:

for (int i = 0; i < 4; i++)
{
	for (int j = 0; j < 13; j++)
	{
				Card[ (i*13) + j ].Pic = i;
				Card[  (i*13) + j].Num = j;
	}
}

You may argue that this code is far less readable. But the fact is that this is more neat.
If you are unsure why is : (i*13) + j you should try to check for some values of i and j

siddhant3s 1,429 Practically a Posting Shark

>>How would I make it so that it counts a value again if it shows up in the array again?
Good question.
The best thing would to use a std::map if you are comfortable using the standard library.

Otherwise, things could get very unhealthy.
Here is what to do other wise if you don't want to use STL:
Run through the test[].
For every i-th element Run through the rest of the array( using a nested loop) and then check if that value repeats ( if yes, find out how many times)
Store the repetition in the count[]

I still strongly suggest you to use std::map.

siddhant3s 1,429 Practically a Posting Shark

You would be getting only suite 3 right?
The problem is in
Card[j].Pic = i;
Card[j].Num = j;
Tell me: should this be j or something else?

siddhant3s 1,429 Practically a Posting Shark

You could also do something like this

for (int i =0,curr_pic=3; i < 52; i++)
	{
	Card[i].Num = i%13;// Num will only get value from 0-12
	Card[i].Pic = curr_pic;
	if( i%13==0) //after every 13 cards increment the value of cur_pic
		cur_pic++;
	}
siddhant3s 1,429 Practically a Posting Shark

You could create a array called count and store the number of occurrence of each of the element of test[] in that. Then simply find the largest element of count[].
Suppose then the largest element of count[] is the k-th element, then the mode will be test[k].

siddhant3s 1,429 Practically a Posting Shark

Oh, Now I got everything Up.
The Textual Reputation what I am inferring are actaully the text in the alt atrubute of the img html tag. Hence whenever one move mouse over one of those green dots, you see those text as Tooltip.
I also discovered that these textual reputation were automated according to number of dots you have.
It must be that Daniweb was a bit down at that time so my browser couldn't load the images. Hence displayed the alt text.
This solves the thread I suppose,

siddhant3s 1,429 Practically a Posting Shark

>>I believe this is how I would input the data but i'm not totally sure on that either...

Run the damn code and tell us if it worked fine or gave error. If error, what error?

siddhant3s 1,429 Practically a Posting Shark

myfile.open ("home/.test.txt",ios::app);

siddhant3s 1,429 Practically a Posting Shark

Boost's Asio is a good one if you want it platform independent:
http://www.boost.org/doc/libs/1_38_0/doc/html/boost_asio.html

I have seen more of platform specific libraries which could suit you.
There is an excelent Beej's Tutorial on Sockets with C, but it works with C++ too. You will need to code like a C programmer with no OOP support. He explains it on *nix platform but also guides how it can be done on windows's winsock
http://www.beej.us/guide/bgnet/

I think this will do, but if you intend to learn more, get the "Unix network programming" book.

siddhant3s 1,429 Practically a Posting Shark

>>something like this? I'm sure it could be done ncer. Untested, so i hope it works.
Wow, he demanded the code, and you gave him. Nothing can get worst than this.
Both OP and you should perhaps read this:
http://www.daniweb.com/forums/thread78223.html
http://www.daniweb.com/forums/announcement8-2.html