Narue 5,707 Bad Cop Team Colleague

>You could also use #pragma once but it is compiler dependent and deprecated.
All pragmas (well, most with the coming of C99) are compiler dependent. You should avoid them whenever possible. And if #pragma once is compiler dependent, how can you say that it's deprecated? Have all compilers documented it as deprecated? Anyway, the only real advantage of #pragma once is that you don't have to worry about naming collisions in your inclusion guards, and that's not worth the loss of portability.

jaepi commented: :) +2
Narue 5,707 Bad Cop Team Colleague

>could you explain what init is?
It's the integer parameter in Month ( int ) ; with a name and a default value.

>... an output function that outputs the month as an integer, blah blah blah
I think you need to get whomever wrote those requirements to give you a better idea of what "input" and "output" mean in this context.

Narue 5,707 Bad Cop Team Colleague

>a constructor to set the month using the first three letters in the name of
>the month as three arguments
That's weird.

>a constructor to set the month using an integer as an argument, a default constuctor
You can merge these guys with a default argument:

Month ( int init = 0 );

>an input function that reads the month as an integer, an input funciton
>that reads the month as the first three letters in the name of the month
These are weird too. I think the terminology is confusing because it sounds like the two member functions are setters, they don't actually take stream input.

>void output ( char , char , char ) ;
Where did this one come from?

>Is this possible without having the three variables char1, char2, and char3
I'd use a string, but if your program requires three characters, you don't have much choice.

>ps) I'm lost as to how to do the output and the object returning functions
Well, assuming the integer is the index of the month (0 = January, 1 = February, ... 11 = December), you can return a new Month object initialized with the next month:

Month::Month nextMon()
{
  if ( month == 11 ) {
    // Wrap around to January
    return Month ( 0 );
  }
  else
    return Month ( month + 1 );
}
Narue 5,707 Bad Cop Team Colleague

Well...this seems like an ideal place to vent. :)

Narue 5,707 Bad Cop Team Colleague

>Because i dislike smoking, and some smokers behaviour.
Hmm, you dislike smoking and some smoker's behavior, so you want to stop this discussion? That sounds very selfish.

>Unless you want to carry on whining about the behaviour of some of the population of smokers.
Anyone who doesn't agree with you is whining, perhaps? If it bothers you that much, just don't read the thread. :icon_rolleyes:

Narue 5,707 Bad Cop Team Colleague

>Lets end this thread with a statement:
Why do you want to end it so much?

Narue 5,707 Bad Cop Team Colleague

If you can sort one column you can sort two. It's just a matter of using the second column to drive your sort, and making sure that when you copy a row, you copy both columns.

Narue 5,707 Bad Cop Team Colleague

>binary search is one thing that you may want to use..
To loop through the elements of an array? Not likely. Maybe you should quote the question you're responding to.

Narue 5,707 Bad Cop Team Colleague

>but my way is best
No, your way promotes ignorance. Mine promotes learning.

>safer (for newbies )
Trading one mystery for another isn't safer.

>and works
Which is why I didn't immediately correct you.

Narue 5,707 Bad Cop Team Colleague

>Actually Narue, I think he was trying to declare an array with a subscript range.
That crossed my mind, but I figured I would go with the most likely intention. ;)

Narue 5,707 Bad Cop Team Colleague

The problem arises when you don't know how C uses stream based input. You can mix input methods without any trouble if you know what happens, but most people just make function calls without knowing what's going on. The ideal fix is to learn how stream I/O works and learn what each input function does.

Narue 5,707 Bad Cop Team Colleague

>Is there another way to pause the program with C, without using system("PAUSE");
Sure. Don't run your program in an IDE that isn't smart enough to keep the window open. Run it from the command prompt.

Narue 5,707 Bad Cop Team Colleague

>thanx ppl i am flattered and that english is called shortcutting
It's called being lazy and cryptic. Not everyone is fluent in English and those people will have trouble reading what you write. Since you have no consideration for other people, we won't have any consideration for you.

>ha ha ha excuse me for being realistic ha ha ha
You're not being realistic. You're being arrogant and rude.

Narue 5,707 Bad Cop Team Colleague

>int range [10, 100];
That's not how you create a multidimensional array. At least, I assume you're trying to create a multidimensional array, which is like this:

int range[10][100];
Narue 5,707 Bad Cop Team Colleague

>Is it possible.
When it comes to C++, if you ask this question the answer will nearly aways be yes. You can do damn near anything with C++.

>If so how may I got the current size of the array.
You're reading a C-style string, and C-style strings always end with a '\0' character. So if you loop until you find one, you know the size of the array:

int i;

for ( i = 0; i < 250; i++ ) {
  if ( array[i] == '\0' )
    break;
}

cout<<"The array is "<< i <<" characters long\n";

The strlen function from <cstring> does this for you.

Narue 5,707 Bad Cop Team Colleague

>hah.. yall like to fight..
It's not often that I get to play with someone as uptight as christina. You should try it, it's a blast. :)

>And I like to prove her wrong.
A lot of people like to prove me wrong. Why? Because it happens so very rarely. And you're not among those who are capable of doing it.

Narue 5,707 Bad Cop Team Colleague

>CNAs are considered nurses here.
"It works for me", huh? That's not an excuse in the software development forums and it's not an excuse here. But you go ahead and keep believing it if it makes you feel superior to us mere patients. I'll just sit here and laugh at you like I always do.

Cheers, "nurse". :D

p.s. I'd probably trust you to take my blood, but being a CNA still doesn't make you an authority on the effects of smoking.

christina>you commented: cheers. ignorance is bliss. even for you. =/ -4
Rashakil Fol commented: don't worry about that bitch +8
joshSCH commented: That isn't nice Rash. Ah hell, this is Narue's post, not Rash's. My Bad :D -3
Narue 5,707 Bad Cop Team Colleague

>Have you ever heard of a CNA?
Yes, and you're right that the minimum age is 16 for becoming a CNA. However, that's not a nurse. That's an orderly. You can't claim to be a nurse just yet, kiddo, so get off your soap box and come back to reality.

>Sure.
Sorry, I missed where that quote says or suggests "smoking regularly". This is a case of you reading between the lines and being wrong.

arjunsasidharan commented: Man.. She is dumb as she looks lol!! +3
Narue 5,707 Bad Cop Team Colleague

>Uh yes a 17 year old nurse. And why in the world would I lie about that?
Because the minimum age for a licensed nurse is 18 and the shortest licensing program is LPN, which takes one year. You do the math.

>You think that smoking regularly is good for the human body
Please quote where I said that. Let's see which of us can't read. :)

Narue 5,707 Bad Cop Team Colleague

>I'm a nurse.
A 17 year old nurse? Even if you're telling the truth, that doesn't suggest that you have a wealth of experience to pull from. Being a nurse also doesn't suddenly make you an expert on the effects of smoking. My mother is also a nurse, so I have some idea of how weak your claim is for supporting your argument.

>And yes, I am right.
No, you're not. You're making claims based on incomplete research. You're applying one or two long-term and overwhelming health problems to your entire argument and completely ignoring any other effects. All you have to do is agree that there are positive effects as well as negative effects and I'll leave you alone. Until then, you're wrong.

>But does this mean that people on the streets should be using and abusing them?
Bzzzt! Nice try Miss Logical Fallacy, but whether people abuse something or not isn't an argument for that thing being bad or good. If you want to go that route, I'll rip you apart with a "food is bad for you because people are fat" counter argument.

>I know how it can be a positive effect on the human body and how it can become a death stick.
Then why are you arguing if you agree with me?

Narue 5,707 Bad Cop Team Colleague

>char *(*c[10])(int **p);
>Ok, what does the above mean ?
The variable c is an array of ten pointers to functions that take a pointer to a pointer to int as a parameter and return a pointer to char. To read a declaration like this you read it from the inside out:

char *(*c[10])(int **p);
        [B]c[/B]                c
        c[B][10][/B]            is an array of 10
       [B]*[/B]c[10]            pointers
      [B]([/B]*c[10][B])[/B]           to
      (*c[10])[B]()[/B]         functions
      (*c[10])([B]int **p[/B])  that take a pointer to a pointer to int
[B]char *[/B](*c[10])(int **p)  and return a pointer to char

Or you can remove parts that are obviously not important, like the return value and parameters. Replace those with void and you can remove three asterisks that might confuse you:

void (*c[10])(void);

Remember that in declarations like this, parentheses mean something. The parens wrapping *c[10] means that this is the central point. If you take away everything else and just add int to the left, you have an array of pointers to int:

int (*c[10]);

With that in mind, you can then remove the array because it's no longer important. You know that the thing is an array, so now you need to know the type of the array:

void (*c)(void);

This is a classic function pointer declaration. The parens say that c is a pointer. If you remove them, it says that c is a function that returns a pointer to void. Now that you know the underlying type is a pointer to a …

Killer_Typo commented: an outstanding breakdown of the given question. +5
Narue 5,707 Bad Cop Team Colleague

>yeah but thats the case with everything
>next peoplem will say that a little heroin is good, but too much....
Okay, then you have to go to the extreme for everything. Not just smoking. Otherwise it will make you a hypocrite who picks and chooses what's good and bad based not on research, but personal bias.

>you get my drift.
No, I don't. If it's the case with everything, why is claiming health benefits to smoking "ridiculous", to quote christina.

Narue 5,707 Bad Cop Team Colleague

>Hmm... that's interesting since I have never heard anyone in the medical
>field proclaim that smoking is good for you. Neither have I read any
>health book stating this ridiculous idea.
Just because you're ignorant doesn't mean you're right. Try looking for studies that link moderate amounts of nicotine to the prevention and treatment of mental disorders. Or studies that have shown nicotine to help ulcerative colitis, increase libido, and improve memory. I remember a study that linked smoking to preventing breast cancer. And of course, due to the effects of smoking we can count stress relief as yet another benefit.

I'm not saying that these benefits outweigh the negative aspects, but I'm also not doing what you are: the text equivalent of putting my fingers in my ears and saying "lalalalala!".

Narue 5,707 Bad Cop Team Colleague

> Smoking is bad for you.
Smoking is good for you, just like chocolate and wine. And just like chocolate and wine, smoking in excess is bad for you.

ndeniche commented: you're sooo right... :D +2
Narue 5,707 Bad Cop Team Colleague

>hope you are clear..bye...
Please learn C before trying to teach it.

Narue 5,707 Bad Cop Team Colleague

>or can you give some model?
The text editor has a watermark that tells you exactly how to use code tags. I don't know how you could miss that, but here's a link to instructions you can't miss.

Narue 5,707 Bad Cop Team Colleague

ranjani, I'm going to ask you nicely just once to use code tags when you post code. Code tags put your code in a nice block and retain any formatting you had. Not using them makes your code an awful mess that nobody wants to read.

Narue 5,707 Bad Cop Team Colleague

>I understand the code
Good for you.

>it was for the C beginners trying to understand the code
Oddly enough, so was my suggestion.

>(as there were 0 comments in his code)
The only comment I would add is 1 at the top describing what the program prints. Beyond that the code is trivial and doesn't need comments.

Narue 5,707 Bad Cop Team Colleague

>Some comments might help the beginners Aia
Read the code with a C reference manual, step through it, and if you still have questions, ask them.

Narue 5,707 Bad Cop Team Colleague
Narue 5,707 Bad Cop Team Colleague

>"error C2059: syntax error '>' "
<> doesn't mean "not equal to". You want the != operator.

>"...could not deduce template argument for 'const _Elem *' from 'char'"
String literals use double quotes and character literals use single quotes. Try s != "q" . Of course, I would be a little suspicious of your logic because even if the string is "q", you still convert and print it.

Narue 5,707 Bad Cop Team Colleague

>a site that gives in depth analysis of C++ programming.
You won't find one.

>I will keep on trying , but I need guidance.
What are we doing if not giving you guidance?

>I am in search of excellent C++ tutorials who could guide me through.
There aren't any tutorials for your exam. You don't seem to realize that C++ is a very large and complicated language. You can't just find a tutorial that teaches you everything. You need to take bits and pieces that you find and incorporate them into what you already know. Then practice. That's how you learn.

Killer_Typo commented: very true words +5
Narue 5,707 Bad Cop Team Colleague

>Why pre-declare variables when C++ doesn't mandate it
Why not? ;) Anyway, my point was that the code is perfectly valid and correct C++ without any changes.

Narue 5,707 Bad Cop Team Colleague

>the site 's code is in c not in c++ and i long for C++
Fine, here's insertion sort from my website after converting it to C++:

void jsw_insertion ( int a[], int n )
{
  int i;

  for ( i = 1; i < n; i++ ) {
    int j, save = a[i];

    for ( j = i; j >= 1 && a[j - 1] > save; j-- )
      a[j] = a[j - 1];

    a[j] = save;
  }
}

>for it doesn't have ->signs
Yes, it does. The arrow operator is just a short form for accessing a structure (or class) member through a pointer. You're sorting arrays anyway, the second insertion sort example is for linked lists. Focus on the first example (which I've pasted above) for now.

Narue 5,707 Bad Cop Team Colleague

>how do i put my source code in tags?
Start by being more perceptive. There's a button on the extended editor that adds code tags for you, and the text editor itself has a permanent watermark with instructions on how to use them.

Narue 5,707 Bad Cop Team Colleague
Narue 5,707 Bad Cop Team Colleague

Your conditionals are a little wacky. In particular this one:

if (num < randNum)
  cout <<uname<<""<<"Your number was too low-please try again!"<< endl;
{
  wins = wins ++;
  break;
}

I'm reasonably sure you don't realize what it's actually doing, which is always incrementing wins and breaking. A little whitespace and extra braces should show you how the compiler sees this:

if (num < randNum)
{
  cout <<uname<<""<<"Your number was too low-please try again!"<< endl;
}

{
  wins = wins ++;
  break;
}

The second block isn't a part of the conditional, it's just an unnamed block that always executes like any other statement. Consider something more like this:

#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>

using namespace std;

int main()
{
  srand ( static_cast<unsigned int> ( time ( 0 ) ) );

  int randNum = rand() % 100 + 1;
  int num = 0;
  int tries = 0;
  string uname;

  cout<<"Please enter your name: ";
  getline ( cin, uname );
  cout<< uname <<'\n';
  cout<<"Welcome to the Random Number Guessing Game!!\n";

  do {
    cout<< uname <<" Enter your choice on the keyboard (#1 - 100): ";
    cin>> num;

    if ( num < randNum )
      cout<< uname <<" Your number was too low-please try again!\n";
    else if ( num > randNum )
      cout<< uname <<" Your number was too high-please try again!\n";
    else // num == randNum
      break;

    ++tries;
  } while ( tries < 3 );

  cout<< uname <<'\n';

  if ( tries < 3 )
    cout<<"Excellent Job!! …
Narue 5,707 Bad Cop Team Colleague

>But what exactly does the hash (or pound) sign do?
It says "this is a preprocessor directive". All preprocessor directives start with that character.

>And, in the quote above, what is "our program?"
"Our program" in this case is the translation unit, which is (put simply) the source code after the preprocessor has run.

>anyone plz correct me if i am wrong
I'm sure you're wrong, but because what you said is basically gibberish, I can't say why it's wrong. ;)

Narue 5,707 Bad Cop Team Colleague

>Sorry, I really didn't want to argue in this forum
Translation: You expected us to immediately agree with you and join your cause without question.

>all I wanted a little support.
Posting on a technology forum isn't exactly the best way to do this. If we're your only means of support, nobody cares enough to help you. Of course, I'm willing to bet that you've been spamming other forums, which makes you lower than the low.

So let me summarize how things work here. If you want to discuss the current laws and state your opinion of how they need to be changed, fine. If you couldn't care less about discussion and only want to further your own selfish agenda, expect to get bashed for it.

Narue 5,707 Bad Cop Team Colleague

>AGAIN, something like sunbathing doesn't harm the people around you
>that choose not to participate whereas smoking does.
Sure it does, unless they use clothing, sun cream, or some form of shielding to protect themselves. Wait, isn't that exactly what smokers are suggesting for non-smokers? :D

Narue 5,707 Bad Cop Team Colleague

A two dimensional array isn't convertible to int*. Change Display and GetValues to take int a[MAX][MAX] as the parameter.

Narue 5,707 Bad Cop Team Colleague

>Yes, but unlike sunbathing, second hand smoke is not something people choose to encounter.
Bingo! Despite the same harmful effects, sunbathing is legal and accepted while smoking is not (of course smokers accept it). And that's my point. It's not about morals or laws, it's about you not liking something and wanting to suppress it. If you're successful (as has been the case in a lot of places) you can then claim to be right because the law, or public opinion, sided with you.

That's all this is.

Narue 5,707 Bad Cop Team Colleague

>Let's be logical here, shall we?
You're using an "x is easier than y" to counter my claim that y is infringing on someone's rights when in reality, both x and y are. I don't see the logic.

>however, it is implied.
Reading between the lines, huh? Wasn't that how the Crusades were started?

Narue 5,707 Bad Cop Team Colleague

>why don't we legalize marijuana too?
Probably because it causes a loss of control and can easily lead to injuries or death. Just like alcohol, which is why bans on drunk driving or being drunk in public are common laws. Tobacco doesn't cause an immediate loss of control to the point where you might accidentally harm someone.

>Why not legalize assault?
Oh, because it causes immediate harm and promotes anarchy? There's a slight difference between assault and cigarette smoking, as any reasonable person would admit.

>It too is something that harms those around them
Only after many years. I have trouble believing that you think immediate grievous harm can be compared to the effects of second hand smoke.

>Smoking has no benefit for anyone.
Nor does sunbathing if you consider the harmful effects over many years. :icon_rolleyes:

Narue 5,707 Bad Cop Team Colleague

>However, his rights end where another's begin.
If that's the case, why are you ignoring the fact that your rights also end where another's begin? ;)

>A smoker does not have the right to smoke at a public place (here,
>anyway) in the same manner that someone is not allowed to shoot
>someone else.
If the law says so, there's nothing we can do about it. But since we're discussing this, I'm assuming we're talking about places where it's not already illegal to smoke in a public place. And if legality is a valid reason, why don't you just say "it's the law" and be done with it?

>This is not a matter of sheer scientific evidence as you say Narue, but of constitutional rights.
I guess I'm not up to date on the Constitution. Could you quote the part that says non-smokers have more of a right to go to public places than smokers?

Narue 5,707 Bad Cop Team Colleague

>Why should he give up his personal liberties to good health as soon as he enters the door?
Interesting. So you want to protect the personal liberties of a non-smoker by suppressing the personal liberties of smokers? Let's chop off all of the health arguments and look at what this really boils down to: You don't smoke. You don't like being around smoke. Therefore, you want to force everyone around you who smokes not to smoke.

You can attach as much reason as you want to it, like research on health effects of second hand smoke, but talking about your own personal liberties while squashing the personal liberties of others is somewhat hypocritical.

Narue 5,707 Bad Cop Team Colleague

>I would hardly call that evidence..
In a thread like this, it's about as good as you're going to get.

>lol.. well, I'd say that you have failed miserably
I wouldn't. But then again, you have no idea what my goals are.

Narue 5,707 Bad Cop Team Colleague

>hahaha... i like it when Narue adds some fire to discussions...
If I don't do it, who will? This place would be a snorefest without me around.

Narue 5,707 Bad Cop Team Colleague

>Wheres the evidence that suggests the majority
>of smokers will stop b/c someone asks them to?
Um, I just gave it.

>Fine, here you go:
I suppose I'll accept that as a workable argument. Now, if you had done it in the first place, there wouldn't have been an issue. ;)

>I guess that's your way of looking at it.
No, I said something I don't really believe because I wanted to confuse you. :icon_rolleyes:

>You're defending the right for smokers to smoke in
>public places where it puts other lives at risk. Duh?
I'm not defending anyone. I'm all for making smoking illegal in indoor public places. What I'm doing is attacking your high and mighty attitude. :)

Narue 5,707 Bad Cop Team Colleague

>Have you even read this thread?
Yes. To summarize, Dave wanted to start conversation and a bunch of non-smokers banded together for four pages of intellectual masturbation.

>...And you're the one talking about rights? =/
I am? Where?

Dave Sinkula commented: The beer nearly went up my nose! +13