WolfPack 491 Posting Virtuoso Team Colleague

Use the continue keyword. It skips to the next iteration.

for (i = 0; i < count;  i++ )
{
        if ( i == 5 )
                continue;

        stuff
}
WolfPack 491 Posting Virtuoso Team Colleague

The reason I think MS charges money for OS is that they think if OS were given out free to people they would end up using Open Source replacements for all MS products and they would be like going down.

I am sorry but I dont understand the logic in this. Care to explain a bit more?

THe main reason MS succeeds is that most of the people who buy PC's are ignorant of the fact that there is something like *Free* OS -- Linux and free as in beer. Most of the people are afraid to experiment and try out non MS products lest something should go wrong.

And usually something will go wrong. Remember these people who are afraid to "experiment" as you say are not geeks unlike us. They are non-techies but who contribute as much as we do to this world. They can be risk takers like enterpreneurs, who has other things to worry about than installing the next OS patch. So the easier they can get their work done, they go for it. For them time is the most important factor. Not hyperthreading or some other technical buzzword. They only want to browse internet, read and send emails. Maybe do some accounting. I know that the command line of Unix is ver yvery powerfull. But try reading email in Pine.

THe bottom line is that MS thrives purely due to publicity and excellent marketing and its contacts and more importantly the ignorance of …

WolfPack 491 Posting Virtuoso Team Colleague

OS is not software in a same sense as MS Office or Corel Draw is. With software like Corel Draw you can DO something. You can produce something that you need for your business. With OS you can't do squat. It is base software and it is NEEDED by windows based software, so if you want to do ANYTHING with, say $2000 gear and $30000 AutoCAD, or $50 video-game, you need to chip in $150 royalty to MS. It is as trivial as the hardware drivers. Imagine paying $150 for each and every driver you have.

Don't you get the driver CD when you are buying a piece of hardware? So don't you think that the cost of the driver is also included for the price that you paid for the hardware? Okay it is not $150, but it has a price right?

Other thing:
If they make OS with flaws (and they do), and they charge money for it (and they do), they should fix any flaw there is. Sure, they are releasing quite bit of fixes (remember, KBs have 6 digit numbers), why all the sudden Vista? Or why XP in the first place? Or NT 4? Or Me? Or 98? Or 95?

My point of view is: OS is OS. XP has same meaning as Vista or NT4.

Well, if you go back in time, that would mean DOS 1.0 is also the same as Vista? You have to realize that developments in technology also …

WolfPack 491 Posting Virtuoso Team Colleague

Gentlemen, let's continue this in the Community Feedback forum shall we?I am moving the posts regarding the syntax highlighting to a new thread. :)

WolfPack 491 Posting Virtuoso Team Colleague

Why are you saying that making money from MS Office is okay and making money from the OS is not? I don't see any difference in them as they both are software, and there is no wear and tear in either of then.

WolfPack 491 Posting Virtuoso Team Colleague

Please, Please drop the "Mr."

Yep. True. It is annoying. :)

WolfPack 491 Posting Virtuoso Team Colleague

Here is one that removes the trailing spaces too.

const int SIZE = 100;
int main()
{
   /*
    *   Remember to initialize char arrays
    */
    char sentence[SIZE] = "";
    std::cout << "Please enter a short sentence: " << std::endl;
    std::cin.getline(sentence, SIZE);
    int len = strlen( sentence );
   /*
    *   Remove trailing spaces
    */
    int i = len -1;
    while ( i >= 0 && isspace( sentence[i] ) )
    {
        i--;
    }
   /*
    *   Check if the array has finished traversing
    */
    if ( i < 0 )
    {
        return 0;
    }
    /*
     * Terminate the sentence before the trailing spaces and
     * update the new length
     */
    sentence[ i + 1 ] = 0;
    len = strlen( sentence );
   /*
    *   Remove leading spaces
    */
    i = 0;
    while( i < len && isspace( sentence[i] ))
    {
        i++;
    };
   /*
    *   Check if the array has finished traversing
    */
    if ( i == len )
        return 0;
   /*
    *   Capitalize the first non-space character
    */
    std::cout << (char)toupper(sentence[i++]);
   /*
    *   Start after the leading spaces
    */
    for ( ; i < len; )
    {
        std::cout << (char)tolower(sentence[i]);
        if (isspace( sentence[i] ))
        {
            do
            {
                i++;
            }
            while( i < len && isspace( sentence[i] ) );
        }
        else
        {
            i++;
        }
    }
    return 0;
}
WolfPack 491 Posting Virtuoso Team Colleague

Maybe I don't have to use isspace?

Yeah. You dont. Consider the use of std::string and std:stringstream.

Anyway this should do for now.

const int SIZE = 100;
int main()
{
   /*
    *   Remember to initialize char arrays
    */
    char sentence[SIZE] = "";
    std::cout << "Please enter a short sentence: " << std::endl;
    std::cin.getline(sentence, SIZE);

   /*
    *   Remove leading spaces
    */
    int i = 0;
    while( i < SIZE && isspace( sentence[i] ))
    {
        i++;
    };
   /*
    *   Check if the array has finished traversing
    */
    if ( i == SIZE )
        return 0;
   /*
    *   Capitalize the first non-space character
    */
    std::cout << (char)toupper(sentence[i++]);
   /*
    *   Start after the leading spaces
    *   Note that this will leave a trailing space,
    *   but that wont be seen.
    */
    for ( ; i < SIZE; )
    {
        std::cout << (char)tolower(sentence[i]);
        if (isspace( sentence[i] ))
        {
            do
            {
                i++;
            }
            while( i < SIZE && isspace( sentence[i] ) );
        }
        else
        {
            i++;
        }
    }
    return 0;
}
WolfPack 491 Posting Virtuoso Team Colleague

Are you reading the sentence all at once, or word by word?

WolfPack 491 Posting Virtuoso Team Colleague

Although I am contributing to an off-topic here...

I read somewhere that females like Sims because it is about relationship building which they are usually good at (although they tend to break those relationships once in a while :P). Sims is more like the digital dollhouse for them.

Men well we like chaos. :D

Me? I like Age of Empires.

WolfPack 491 Posting Virtuoso Team Colleague

From where u got this...

I got it from here.

WolfPack 491 Posting Virtuoso Team Colleague

Yay

He's being quite superstitious regarding something.

Thank god for astrology. :cheesy:

WolfPack 491 Posting Virtuoso Team Colleague

Now that we are talking about icons, don't you like Dragon's old avatar better? The current one is too cute for a dragon.

[IMG]http://www.clicksmilies.com/s0105/wuerg/vomit-smiley-011.gif[/IMG]

WolfPack 491 Posting Virtuoso Team Colleague

Well, I remember reading about [search]ReactOS[/search] in a Daniweb blog a couple of months back. I don't think Microsoft can sue it because they are taking steps so that they do not use any illegal means to develop this OS. And since it has been around for 10 years, I do not think it has got anything to worry about along those lines. That said, I am not a legal expert in these things, so there may be other issues that need to be addressed. But whether it will make huge dent in the Microsoft OS market share remains to be seen. Honestly I do not think so.

WolfPack 491 Posting Virtuoso Team Colleague

my dads friend had a heart transplant and now he dreams in back and white

Ah that explains it. I had a change of heart too.

WolfPack 491 Posting Virtuoso Team Colleague

she is getting married to Abishek Bacchan

:sad:

WolfPack 491 Posting Virtuoso Team Colleague


But, India: I absolutely love the food (my favorite, actually), I really like the music, and from what we hear of India in the States, a massive tech boom especially on the software front. :)

And Aishwarya Rai. *sigh*

WolfPack 491 Posting Virtuoso Team Colleague

Winter in India :D

You have Winter in India? :eek:.
Which part of India do you live in?

WolfPack 491 Posting Virtuoso Team Colleague

WolfPack:
, could you please explain this above code to me a bit in your own words?

the heart of the function convert_to_int that converts the string to int is the strtol function.
From the documentation you see that it gives you the long value of a string. If there was a character that couldn't be converted, e.g. an alphabetic char, the value of end will be that character. that is the meaning of

end is set to point to whatever is left in start after the long.

. So once the convertion is finished, you check the value of end , and if it is not null, that means some character that was not conversible is in the chracter string. If that happens return an error and exit. You can even throw some kind of exception because this is C++. input.c_str() is how to get a non-modifiable pointer to the characters contained in it.

Hope this explaination suffice.

WolfPack 491 Posting Virtuoso Team Colleague

I dont even remember what I dream..

I just woke up from a dream in which I was tied to a chair of an Art Review. (Not joking).:eek:. Care to intepret that?

WolfPack 491 Posting Virtuoso Team Colleague

I dreamt of coding.

Remember seeing in a previous post that you dreamt of daniweb also.:confused:

Are you sure that you have a girlfriend? It is more likely to be a hallucination of Dani. :P:eek:

WolfPack 491 Posting Virtuoso Team Colleague
WolfPack 491 Posting Virtuoso Team Colleague

playing with lava

WolfPack 491 Posting Virtuoso Team Colleague

Good. Mind posting the solution so that someone else can learn from it?
Thank you.

WolfPack 491 Posting Virtuoso Team Colleague

Comment out section by section and locate which part gives that error. After that post it here. Since we don't have the input files, we can't reproduce the error here. The file is also too long for us to wade through all the code.

WolfPack 491 Posting Virtuoso Team Colleague

All my dreams are in black and white... Do any of you dream in colour?

WolfPack 491 Posting Virtuoso Team Colleague

You play the double game when you do not, "say what you do, and do what you say".

WolfPack 491 Posting Virtuoso Team Colleague

Why don't you read the documentation for Sleep() ????

WolfPack 491 Posting Virtuoso Team Colleague
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
long convert_to_int(const char* input )
{
    char* end = 0;
    long choice;
    choice = strtol( input, &end, 10 ) ;
    if ( *end != NULL )
    {
        cout << "couldn't convert " << input << " to int\n" ;
        return 0;
    }
    else
    {
        cout << "Number " << choice << "\n" ;
        return choice;
    }
}
int main () 
{
    string input = "10";
    convert_to_int(input.c_str());
    input = "10.000";
    convert_to_int(input.c_str());
    input = "a";
    convert_to_int(input.c_str());
    return 0;
}
WolfPack 491 Posting Virtuoso Team Colleague

C or C++?

WolfPack 491 Posting Virtuoso Team Colleague

Somebody needs a girlfriend... I can give you a discount on a slightly used Girlfriend 1.0...

Won't her software be incompatible with my hardware? Cos Girlfriend 1.0 was released, how many ..., 20 years ago?

Yeah maybe then there would be someone to kick Wolfie when he makes sarcastic comments. :cheesy:

As long as she only kicks and keeps the boot WITH HER, I wouldn't mind.

WolfPack 491 Posting Virtuoso Team Colleague

What Dragon said. Since I did the corrections anyway, here they are.

  • Remember not to use eof to test if the file hasnt finished reading.
  • Remember to initialize arrays or any variable if you are not sure that you will be inputting values.
  • Because your delimiter is a character other than '\n', you will usually have to process 2 getlines. Refer the code.
// reading a text file
#include <iostream>
#include <fstream>
#include <sstream> // New addition. Needed for stringstream- WoLfPaCk
#include<iomanip> 
using namespace std;
 
//FONCTION LireInfo
void LireInfo (char Noms [80][30])
{
    //Variables
    int x, y, Counter=0;
    //Instructions
    ifstream fichier ("employe.txt");
    if (fichier.is_open())
    {
        string token;
        stringstream ss;
        int line_count = 0;
        while (getline (fichier,token) && line_count < 80)
        {
            ss.str(token);
            ss.getline( Noms[ line_count ], 30, ':' );
            ++line_count;
        }
        fichier.close();
    }
    else 
        cout << "Ooops"; //if file doesn't open properly
    for (y=0; y<80; y++) //loop to show the array
    {
        for (x =0; x <30; x++)
        {
            cout<<Noms[y][x];
        }
        cout<<endl;
    }
}
 
//MAIN 
void main () 
{
    //Variables
    char Noms [80][30] = { 0 }; // Remember to Initialize
    //Instructions
    LireInfo(Noms);    
}
WolfPack 491 Posting Virtuoso Team Colleague

Why are you using the strcpy function? These are C++ strings. Use the = operator.

thisRecord.fieldName =next
WolfPack 491 Posting Virtuoso Team Colleague

Is this related to C++ only or OOP in general? Because if it is in the general sense, I think this thread is much suited to the Computer Science and Software Design Forum.

WolfPack 491 Posting Virtuoso Team Colleague
WolfPack 491 Posting Virtuoso Team Colleague

Rumor has it he's been snorting lines of "C"... :mrgreen:

Funny you asked. I quit smoking last Sunday.

WolfPack 491 Posting Virtuoso Team Colleague

Honestly I haven't got anything better to do in my freetime.

WolfPack 491 Posting Virtuoso Team Colleague

Looks like your project doesn't have a main function in any of the source files.

WolfPack 491 Posting Virtuoso Team Colleague

Here is what happens when you get Bad rep, and now imagine if it was not annonymous. :mrgreen:

WolfPack 491 Posting Virtuoso Team Colleague

better than being sterile in young age though....

WolfPack 491 Posting Virtuoso Team Colleague

gee sowwyy....

WolfPack 491 Posting Virtuoso Team Colleague

WOMBAT:cheesy:

WolfPack 491 Posting Virtuoso Team Colleague

Man.. one day you'd make one hell of an obituary writer.

WolfPack 491 Posting Virtuoso Team Colleague

Don't need the compound if. if ((intNumb % intDivider) == 0) will suffice.

Looks like I interpreted the meaning of dividing evenly incorrectly.

Say for example intNumb = 6 and intDivider = 2. Clearly intNumb is divisible by intDivider, so intNumb % intDivider == 0 is true. But the quotient is 3, which is odd. So I thought intNumb is not divided evenly by intDivider. Hence the second test.

Did some searching, and WaltP is correct. So no need for the second part of the comparison.

WolfPack 491 Posting Virtuoso Team Colleague

Thank god for that last part for us males. :cheesy:

WolfPack 491 Posting Virtuoso Team Colleague

so i just cant figure how to check: "if the counter divides the number evenly;"

Something like

if ( intNumb % intDivider == 0 &&  (intNumb/intDivider)%2 == 0)
{
          // intNumb is divided by intDivider evenly
}

I hope I got the meaning of dividing evenly correctly.

WolfPack 491 Posting Virtuoso Team Colleague

In the above code, wouldn't it be more memory conservative if the definition of bool setvalue(...) was not "inline" but defined in player.cpp?

tictactoe::tictactoe.setvalue(...)
{
...
}

In this case also the setvalue function is not inline. Even if you declare it in the header file, you have to use the inline keyword to make it inline. So moving it to the player.cpp file will not make a difference. But usually all definitions are moved to the .cpp file to make the header file less bulky and to hide the implementation.

I ask this since i thought I read that there will be less copies made this way.
do i have that correct ?

Yes. If the function is not inline the function will be called at runtime instead of embedding it during compile time (copied everywhere it is needed to be called). But using inline will make the executable file size more bulky, although the execution will be faster. So usually only small functions like get or set functions are declared as inline.

WolfPack 491 Posting Virtuoso Team Colleague

You may have misunderstood me. You seem to have it backwards.

Without doing anything to the program, it will not link.

If you comment out the #define NOT_WORKING, then the program links and runs.

I'm using g++ 4.0.1 on a Mac as well as xlC version 8 on AIX to test with. Both agree in both cases.

Thanks for helping.

No. I am sure I have not misunderstood. It links and runs allright in both the cases. Check if you have posted the correct code.
These are the outputs.


#define commented out

0
1
2
3
Press any key to continue

#define not commented out

0
1
2
3
0
1
2
3
Press any key to continue
WolfPack 491 Posting Virtuoso Team Colleague

Dont you think the "typename" should be replaced with "class" ?

Why is that?

WolfPack 491 Posting Virtuoso Team Colleague

Are you sure? I can compile your code even when the #define NOT_WORKING is commented out or not. However I get an unreferenced g variable when it is commented out.