Narue 5,707 Bad Cop Team Colleague

>To anyone reading this thread:
You realize the thread is over three years old, yes?

>getch() is still available in the conio.h header file (at least in MinGW).
I'm sure it works just fine on your compiler, but because it's non-standard, that means it's not guaranteed to work on my compiler, or someone else's compiler. Is this that difficult of a concept for you people to grasp?

>cin.get() acts the same as getchar() - it echos the
>pressed key and waits for enter to be pressed.
Assuming that's what getchar does. getchar makes a call to a system function that performs the actual read, and that system function (whatever it may be) isn't required by the C++ standard to provide cooked input. However, I'll give this to you because I can't think of any systems off the top of my head that don't buffer up to a line feed. It's a safe assumption.

>And don't worry, Narue is wrong
Narue is always right[1]. You'd do well to realize that before truly embarrassing yourself.

>iostream is very standard for C++.
<iostream> is standard, <iostream.h> is not. Once again, this is a very simple concept, but I'll assume that you're just having trouble with reading for comprehension and missed the ".h" part.


[1] I'll qualify this. Narue is always right when it comes to the likes of you. I do make mistakes, but I get the strong impression that …

William Hemsworth commented: Narue IS always right, from my experience ;) +4
Narue 5,707 Bad Cop Team Colleague

If you want the character representation of a digit, wrap it in single quotes:

if (studentId[3] == '1')
    cout << "Freshman ";

else if (studentId[3] == '2')
     cout << "Sophmore ";

else if (studentId[3]  == '3')
     cout << "Junior ";

else if (studentId[3] == '4')
     cout << "Senior ";
Narue 5,707 Bad Cop Team Colleague

>%02.3f
The field width is the total number of printed characters, not the number of characters before the radix. Try "%06.3f" instead.

challarao commented: short and precise +1
Narue 5,707 Bad Cop Team Colleague

>I'd much rather read everything in as a string then convert to ints or doubles wherever necessary.
You're so boring, iamthwee. Why do things the conventional way when you can flex your brainy muscles and solve a problem the hard way? :)

Narue 5,707 Bad Cop Team Colleague

When you want to remove extraneous characters from an input stream in C++, it's usually because you mixed formatted and unformatted input methods. The formatted method would leave a newline in the stream and the unformatted method would consume it and terminate successfully, but fail completely to do what you wanted.

#include <iostream>

int main()
{
  std::cout<<"Enter the letter A: ";
  std::cin.get();
  std::cout<<"Enter the letter B: ";
  std::cin.get();
  std::cout<<"Too late, you can't type anymore\n";
}

Often this question stems from another question, which is how to pause a program before it terminates. Using cin.get() works only when there are no characters left in the stream. The instant you throw a cin>> foo; in the code, suddenly the solution fails. You need to clear out any leftover characters from the stream before it'll work again.

So how do you fix the problem? The good news is that unless you want to get picky, it's as simple as a loop:

#include <istream>

void ignore_line ( std::istream& in )
{
  char ch;

  while ( in.get ( ch ) && ch != '\n' )
    ;
}

This loop simply reads characters until end-of-file or a newline is read. It's generally assumed that interactive input in C++ is line-oriented and you're guaranteed to have a clean buffer after reading a newline. While that's not true (input doesn't have to be line-oriented), it's wide spread enough that we can assume it for the purposes of this thread.

So what's wrong with this …

SpS commented: Amazing +4
Dave Sinkula commented: You will save me much typing. +11
Narue 5,707 Bad Cop Team Colleague

>#include <iostream.h>
I'll let that slide because you're using a compiler that's roughly the same age as dirt.

>#include <conio.h>
This I won't let slide. You have no reason to use conio, and I'll explain why shortly.

>void main() {
I don't care if the compiler lets you do it, void main is wrong and it always has been. The only two correct ways to define main in C++ are as follows:

int main()
{
  return 0; // With a newer compiler you can omit this
}
int main ( int argc, char *argv[] )
{
  return 0; // With a newer compiler you can omit this
}

>clrscr();
1) This is completely unnecessary.
2) It's completely anti-social because you lose the output of previous programs.
3) It destroys any portability your code might have had.
4) The cool kids don't use it, and you want to be cool, right?

>sum = sum + i;
I suppose you meant this instead:

sum = sum + ( 2 * i );

>cout<<"\b\b ="<<sum;
Those backspaces are messing up your output, I don't see why you even need them.

>getch();
1) This is completely unnecessary.
2) It's easy to get similar behavior with getchar.
3) It destroys any portability your code might have had.
4) The cool kids don't use it, and you want to be cool, right?

Sturm commented: the "cool kids don't use it" lol +2
Narue 5,707 Bad Cop Team Colleague

>but how do classes access variables in other classes?
There are

1) Make the data members public, then anyone can access them:

class test {
public:
  int foo;
};

int main()
{
  test t;
  t.foo = 123;
}

2) Make the data members protected, then derived classes can access them:

class test {
protected:
  int foo;
};

class derived: public test {
public:
  void bar() { foo = 123; }
};

3) Make the function or class that accesses a data member a friend of the class:

class test {
  friend void bar ( test& t );
  friend class baz;
private:
  int foo;
};

void bar ( test& t )
{
  t.foo = 123;
}

class baz {
public:
  void blah ( test& t ) { t.foo = 123; }
};

4) Provide a public or protected member function that accesses the data member:

class test {
private:
  int foo;
public:
  int get_foo() { return foo; }
  void set_foo ( int value ) { foo = value; }
};

int main()
{
  test t;

  t.set_foo ( 123 );
  int bar = t.get_foo();
}

>I am completely lost on how to write the Orders class so that I can output the Pizza information.
Okay, a pizza contains all of its information, right? And an order is just a collection of pizzas. So what you want to do is have the Pizza class provide a way to print or return its information so that the …

Duki commented: great explanation +4
Narue 5,707 Bad Cop Team Colleague

>error C2679: binary '=' : no operator found which takes a
>right-hand operand of type 'TCHAR [260]'
Yep, it looks like you're trying to initialize a narrow string with an array of wide characters. Try using std::wstring instead of std::string.

Narue 5,707 Bad Cop Team Colleague

>I mean, if it wasn't explicitly in the standard that 'the pointer will be unchanged on failure',
>implementors of the cstdlib library could be free to implement the internal workings of the
>function it in their own way
True, but the behavior in this case is carefully specified by the standard. strtod breaks the source string into three parts: leading whitespace (possibly empty), a legal floating-point representation, and trailing unmatched characters (including '\0'). Provided the second argument isn't a null pointer, it's guaranteed to be set to the first character in the third part. If the second part is empty (ie. strtod completely failed to match a floating-point value), the second argument is set to the source string.

You can test these rules fairly easily:

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

const char *check_strtod ( const char *s )
{
  const char *end;

  printf ( "%f\n", strtod ( s, &end ) );

  return end;
}

int main ( void )
{
  const char *p;

  /* Full match, end points to '\0' */
  assert ( *check_strtod ( "123.456" ) == '\0' );

  /* Full match after leading whitespace, end points to '\0' */
  assert ( *check_strtod ( " \r\n\t\v\f123.456" ) == '\0' );

  /* Partial match, end points to unmatched string */
  assert ( strcmp ( check_strtod ( "123.456abcdef" ), "abcdef" ) == 0 );

  /* Partial match after leading whitespace, end points to unmatched string */
  assert ( strcmp ( check_strtod ( "   123.456abcdef" ), …
MattEvans commented: Thankyou, that put my mind at rest. +4
Narue 5,707 Bad Cop Team Colleague

>mName = c1 + c2 + c3 ;
This doesn't do what you think it does. c1, c2, and c3 are all integral values, so the + operator performs integral addition, not string concatenation. Why not just read the input into a string from the start?

void setMbyN ( istream & is )
{
    const string months[] = {
      "jan", "feb", "mar", "apr", "may", "jun",
      "jul", "aug", "sep", "oct", "nov", "dec"
    };

    string mName;

    is>> setw ( 3 ) >> mName;

    for ( string::size_type i = 0; i < mName.size(); i++ )
      mName[i] = tolower ( mName[i] );

    month = 0;

    for ( size_t i = 0; i < 12; i++ ) {
      if ( months[i] == mName ) {
        month = i + 1;
        break;
      }
    }

    if ( month == 0 )
      throw runtime_error ( "Invalid month" );
}
Duki commented: great function! worked excellent! +4
Narue 5,707 Bad Cop Team Colleague

>By default, the standard input in c is in the canonical mode, which means that all input is
>line buffered and the line would be received only after the linefeed.
That's not how buffering in C works. You're confused about the connection between a command shell and a C program. Canonical mode in a command shell is separate in that the shell's input buffer collects input and allows editing of that input before passing it on to the running program. Non-canonical mode sends characters directly to the running program as they're received by the shell. The running program doesn't know or care about the shell's buffering, it simply fills a stream with characters.

Line buffering is the default in C, but that buffer is different than the command shell's buffer in that it's used for performance reasons, not behavior reasons. You can switch I/O in C to be non-buffered and still be limited by the canonical mode of your shell.

What you mean with canonical mode is how the operating system handles I/O, which isn't covered by standard C, so system-dependent API calls need to be made to change the behavior of the I/O interface used by the standard C functions. This is made most obvious by the fact that your hello world program still uses the standard getchar function. You're not changing how standard C works, you're simply using non-standard functions to change how the system functions that standard C uses work.

>Oh yes …

Rashakil Fol commented: You evil wench! +6
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

Your vector doesn't have any elements to assign to. You need to set the initial capacity, or insert new elements with push_back:

#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
  vector<vector<string> > edge_set_test ( 1, vector<string> ( 2 ) );

  edge_set_test[0][0] = "1";
  edge_set_test[0][1] = "0";

  cout<<"\nTesting values "<<edge_set_test[0][0]<<" "<<edge_set_test[0][1];
}
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
  vector<vector<string> > edge_set_test;

  edge_set_test.push_back ( vector<string>() );
  edge_set_test[0].push_back ( "1" );
  edge_set_test[0].push_back ( "0" );

  cout<<"\nTesting values "<<edge_set_test[0][0]<<" "<<edge_set_test[0][1];
}

Alternatively, you can combine the two:

#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
  vector<vector<string> > edge_set_test;

  edge_set_test.push_back ( vector<string> ( 2 ) );
  edge_set_test[0][0] = "1";
  edge_set_test[0][1] = "0";

  cout<<"\nTesting values "<<edge_set_test[0][0]<<" "<<edge_set_test[0][1];
}
GreenDay2001 commented: Nicely Explained +3
Narue 5,707 Bad Cop Team Colleague

>Can anyone help me.
Yes.

Duki commented: rofl +4
Narue 5,707 Bad Cop Team Colleague
Ancient Dragon commented: good link +18
Narue 5,707 Bad Cop Team Colleague

>i had wondered how to allocate more instead of using a constant char foo[100];
It's great, you can use a similar syntax to allocate more than one:

char *p = new char[100];

This creates 100 characters and points p to the first of them.

>i remember someone posting about using cin.flush to remove any characters from the buffer
They were probably wrong. I say probably because flush is a valid operation on an ouput stream. It forces any characters in the stream buffer to be written to the destination.

Killer_Typo commented: + cool points for being so informative +6
Narue 5,707 Bad Cop Team Colleague

Just because the array is a member of a structure doesn't mean you can suddenly assign to it. Array assignment isn't allowed in C, but you can do a structure initialization to the same effect:

test newTest = {1,2,3,4,5};
iamthwee commented: omg I just noticed your new site. It's soooo cute, with its new colour scheme and the javascript in the code. :) +11
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

Okay, then post your exact code so that I can try it out.

vedro-compota commented: ++++++++++ +3
Narue 5,707 Bad Cop Team Colleague
/* main.c */
extern void foo ( void );

int main ( void )
{
  foo();
  return 0;
}
/* print.c */
#include <stdio.h>

void foo ( void )
{
  puts ( "foo!" );
}

That's all it takes. In fact, you don't even need the extern keyword for the prototype (but it aids clarity). If that's what you're doing, can you explain how the compiler "refuses to work"?

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

> 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

>I know some C/C++ right now, and no Java.
Let me clear this up for you right now. C/C++ is for experts only. C and C++ are two different languages and you would be wise to learn only one at a time. When people say C/C++, they mean some combination of C and C++ that can only be correctly written by someone proficient in both.

Infarction commented: Well said. +7
Narue 5,707 Bad Cop Team Colleague

Here's my contribution:

int main()
{
  return 0;
}

The rest is up to you until you learn how to ask a smart question.

Aia commented: Bug free. +6
Narue 5,707 Bad Cop Team Colleague

I guess this thread is used for reporting too. I won my game against sk8ndestroy14. Thanks for the good game, and I hope to see you again on the flip side. :)

joshSCH commented: Happy Independence Day! =) "(9:02:52 PM) Dave: I haven't followed it much since advising Josh to advise him." -Tuh, bull crap.. that was all my pimp ass :) +15
Narue 5,707 Bad Cop Team Colleague

A static function is a function with the static qualifier applied:

static void foo ( void )
{
  /* Blah blah */
}

What it does is restrict visibility of the function to the translation unit in which it's declared. Functions are implicitly declared as extern by default, which means they're visible across translation units. You can compile the following, but it won't link:

/* file1.c */
void foo ( void )
{
}

extern void bar ( void )
{
}

static void baz ( void )
{
}
/* file2.c */
void foo ( void );
void bar ( void );
void baz ( void );

int main ( void )
{
  foo(); /* OK: foo is extern by default */
  bar(); /* OK: bar is explicitly extern */
  baz(); /* Wrong: baz isn't visible in this translation unit */
}
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

>Do you ever stop?!
No.

>I didn't realize that you couldn't do that in a BLOG.
What? Take someone else's work and post it as your own? That kind of applies everywhere, don't you think?

>You can stop with the harassing remarks now.
I'm not harassing you. You're just too sensitive.

arjunsasidharan commented: Hee hee.. +3
Narue 5,707 Bad Cop Team Colleague

>It makes me wonder how safe rides really are.
Very safe. It's certainly unfortunate, but the occasional accident shouldn't scare you away. The design, construction, and maintenance of these rides are done with a careful eye toward rider safety. From the story, it sounds like defective material somewhere along the line slipped through QC.

maravich12 commented: love your new avatar;) +2
joshSCH commented: No, it sucks! Screw wolfy, you shoulda gone with mine! ;) -3
WolfPack commented: Nope. My choice was the best. +10
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
Narue 5,707 Bad Cop Team Colleague

>If people's choices are hurting others then yea, it is our
>business, and we can tell them how to live their lives

>When it endangers other lives. Of course!

And naturally you're qualified to make that choice. :icon_rolleyes: Tell me, have you ever thought to ask a smoker not to smoke around you? I have, and to date nobody has ever refused to give me space or put out their cigarette when I asked politely. Most of the time they immediately put it out and don't light up again while I'm around. Smokers aren't evil people who intentionally try to hurt you, so stop trying to act righteous.

Aia commented: Asking is always nice. Forcing is "almost" always wrong. +5
Narue 5,707 Bad Cop Team Colleague

>Secondly sarcasm is the lowest form of wit.
I have to resort to the lowest form of wit for you to appreciate it.

>So i have not studied any GUIs MFC or otherwise for c++.
You've done research on MFC and indicated that as far as you can tell, it was for meant for C. That means your research was extremely limited, or you simply didn't read for comprehension.

>I am not sure that Microsoft would care.
That's utter BS. Microsoft puts a lot of effort into backward compatibility. It goes to the point of patching the OS to work around a special case of a single application that did the wrong thing in the first place just to keep people like you from blaming Microsoft for a crappy application that they didn't even write.

>Not letting something work is a good way of being paid for it again.
Not letting something work is a good way to go out of business. You don't seem to understand that if you break things in a new system that worked on the old system, nobody will want to use the new system.

WolfPack commented: Honesty is the best policy +10
Narue 5,707 Bad Cop Team Colleague

>and think that I can easily persuade people with science and logic.
Many people can't be convinced by logic unless they're already half way to believing what you're trying to convince them of. If someone has a strong opinion, it's impossible to change their mind with logic. But it doesn't mean you can't have fun with them. :) Here is a recent example that I've been enjoying.

joshSCH commented: b/c I'm nice :) +11
Narue 5,707 Bad Cop Team Colleague

>I've never really known someone that has forced their children into religion.
Saturating their life with a religion when they don't know better is the same as forcing them into it. I recall being told to go to church, pray before every meal and before bed every night, amongst an otherwise awkward expectation that I should be religious if I want to be a good person.

I feel that it was because I was surrounded by religion from such a young age that I had so much difficulty coming to terms with my beliefs, and why to this day I feel uncomfortable around a lot of my family. And I still wouldn't say that my family is exceptionally devout. Probably less so than many church going families.

Narue 5,707 Bad Cop Team Colleague

Were you born dumb or does it take practice?

linux commented: Hehe... That made me laugh. +1
joshSCH commented: haha... He must have practiced quite a bit.. +11
Narue 5,707 Bad Cop Team Colleague

>lease do anyone among you know about c software execution optimization..
Yes.

Salem commented: Me too :) +7
Narue 5,707 Bad Cop Team Colleague

>s visual c++ 2005 one of these forms?
Yes, you can write standard C++ in Visual Studio 2005.

>i took it you meant that visual c++ 6.0 does not work with the standard language?
Correct. Visual Studio 6 was released before the C++ standard came out, so it isn't very compliant.

>if you pick up a text book which just say C++ without any reference to
>microsoft or dot net or borland i asume that you have a ninety percent
>chance of reading aboout this standard c++.
If the book was also printed after around the year 2000, yes. Two good indicators of a non-standard book are looking for void main and headers with a .h suffix.

>and also i take it that this standard language is the "only one form of
>c++" which you talked about earlier in this thread?
Yes, only the C++ standard can tell us what C++ is or is not. Anything else is an extension or a dialect.

>if that is true then why did microsoft went through the trouble of
>creating its own form of c++ for 6.0?
Prior to the C++ standard we had the de facto standard defined in a book called The ARM (The Annotated C++ Reference Manual). Most older compilers followed the definition of C++ from that book, and/or followed cues from Stroustrup's compiler. Of course, since neither was an official standard, many compilers supported a slightly …

quintoncoert commented: Extremely helpfull +1
Narue 5,707 Bad Cop Team Colleague

>sorting the list should help.
Sorting the list with a general algorithm gives you (at best) O(NlogN) performance just for the sort. Then you have to determine the duplicates. It also means that you have to store the list somewhere first, which means your storage cost is O(N). If there are a lot of duplicates, you're wasting storage for this problem. See below.

>this would take O( N log N ).
That's a curious solution. Why didn't you go with a map instead?

#include <cstdlib>
#include <iostream>
#include <map>

int main()
{
  std::map<int, int> freq;

  for ( int i = 0; i < 30; i++ )
    ++freq[std::rand() % 20];

  std::cout<<"Duplicates:\n";
  std::map<int, int>::iterator it = freq.begin();

  while ( it != freq.end() ) {
    if ( it->second > 1 )
      std::cout<< it->first <<" -- "<< it->second <<" times\n";

    ++it;
  }
}

Not only does this give you a unique list, it also marks each of the duplicates for later use. That's a great deal more flexible than what you have, which can only mark duplicates once.

Of course, it still has a storage problem because of the counter for each item. Even if you use the map as your primary data structure rather than the vector you're using now, it's still effectively a 2N storage cost for integers. Since the OP only seems to want the duplicates, you can remove all but the duplicates with fair ease and limit the storage penalty to when nearly every number …

iamthwee commented: good idea and nicee avatar +10
Narue 5,707 Bad Cop Team Colleague

>hey, how would i go about converting a char* character array to a double.
Provided the array is actually a string with a terminating '\0' character at the end, you can use strtod. Or, since this is C++, stringstreams make the conversion intuitive if you're used to cin and cout:

#include <sstream>

double to_double ( const char *p )
{
  std::stringstream ss ( p );
  double result = 0;

  ss>> result;

  return result;
}
ryuslash commented: Just what I was looking for :D +1
Narue 5,707 Bad Cop Team Colleague

>it had been a long time since i got you mad at me huh narue?
If you want to get me mad, keep using jeje. It's a big pet peeve of mine. I used to play a game called X-wing vs. Tie Fighter and was actually one of the better players in the world. There was a club that insisted on speaking spanish (which was rude enough but we let it slide) and always (like, every sentence) used jeje or jaja. It annoyed me so much that I went out of my way to play games against them as much as possible to make sure they got raped on a regular basis. I'm not sure, but I think I was one of the reasons they disbanded.

Narue 5,707 Bad Cop Team Colleague

>I have been working on this school project and have figured out every step but two.
>
>So far I have everything done, and my stumbles are on #4
>
>Also on #6 I can add the explanation point to the end of the words that
>are longer that 8 characters but not to the ones that are shorter.
I'm seeing slight contradictions here.

>word.erase (8,20);
Where does 20 come into the picture? The second argument defaults to npos, so you can just say word.erase ( 8 ) and the string class will do the right thing.

>word.replace(6,1, "#"),word.insert(8,"!");
Um, overkill? Why not just say word[6] = '#'; ? And append would be a better choice than insert here. Of course, since this is the last operation for the line, you can just print a bang character and call it good without modifying the string. Also, this is an extremely poor use of the comma operator. Separate operations should be on separate lines:

word.replace(6,1, "#");
word.insert(8,"!");

Also, you only append the bang in this condition, but the requirements seem to want it all of the time.

>else if (word.length()<=8)
If the word is exactly eight characters, you don't need to append with 'B's. Your logic is broken here, but the body of the condition hides it from you.

>word.insert (8 - word.length(),"B");
This doesn't do what you think it does. It inserts the string "B" …

WolfPack commented: お疲れ様でした。 +8
arjunsasidharan commented: What does that mean wolfpack? the chinese letters? +3
Rashakil Fol commented: Those are Japanese. +6
Narue 5,707 Bad Cop Team Colleague

I'm most certainly not a fan of Weiss' code, but the book you have is half decent in terms of coverage. His stuff is noticeably dumbed down, but if you want to take your trees to the next level, try this.

~s.o.s~ commented: Good thing you updated your site. Too bad there is no button for commenting.. ;-) +20
Narue 5,707 Bad Cop Team Colleague

>ok, I cant make you believe a person with a Ph.D.
I don't believe people just because they have a PhD. I also tend not to believe people who have a strong opinion about something because it suggests they lack the vision to see more than their own beliefs. :)

>How about refuting the 14 points instead of attacking the source?
I'll pass. Political discussions are tedious and boring to me. And you strike me as painfully stubborn, so getting into any kind of debate with you would be nothing more than a waste of time. But if I were to do so, I would probably do it by showing how I can use careful phrasing to make America look like anything I want it to.

jbennet commented: :) +16
Narue 5,707 Bad Cop Team Colleague

>Good grief Charlie Brown, where is the answer to EnderX in all this senseless squabble?
That would be posts 2 and 4. And squabbles are only useless if they're uninformative.

>Nice spin. Your good.
I've never claimed to be anything but.

>What's a rule except a guideline suggestion gone dictatorial?.
Not much. What's your point?

>After all they were who suggested those guidelines. Oh, well.
Believe it or not, people and opinions change.

>And next time that you "blast" any newbie I'll be there with
>encouragement saying to her or him. It is nothing more that her "suggestion; a guideline".
And when it's actually a rule, I'll be sure to trim your little ego back to size.

iamthwee commented: Yeah you go girl! +9
Aia commented: Yeah, you go girl! +3
Narue 5,707 Bad Cop Team Colleague

>Everyone is so nice......
You post in the wrong forums then.

Aia commented: You are Absolutely +3
Rashakil Fol commented: :-) +6
Narue 5,707 Bad Cop Team Colleague

>You can use atoi to convert the char to a int
Or not, seeing as how atoi is a demon spawn. Use strtol instead, or since this is C++, stringstream or Boost::lexical_cast. Examples are common and can be found with this forum's search feature.

WolfPack commented: best answer +8
Narue 5,707 Bad Cop Team Colleague

>dont make your explanation too complex, as i am only 19.
19 easily makes you an adult, so that's not an excuse to pretend you're stupid. Perhaps "I'm not too familiar with the topics, so don't make your explanation too complex".

>if you could tell me what the course entails,and if its difficult.
Look at the course syllabus for details on what you're expected to learn. And yes, both topics are rather difficult. You'll probably find computer science more difficult as it goes far deeper into theories and mathematics.

joshSCH commented: This is for putting up with that ass**** =) +7
Narue 5,707 Bad Cop Team Colleague

>What about the other 96% of energy and matter surrounding us?
What about it? Our understanding of science is extremely primitive. People who think we're technologically advanced, assume anything we don't know is unknowable, and then start to put a divine spin on things just make it harder to view the universe objectively. Religion is all well and good if you need that sort of thing to bring you comfort, but as a scientific explanation of who we are and where we came from, it's pretty weak.

joshSCH commented: =) +6
Sturm commented: nice... +1
Narue 5,707 Bad Cop Team Colleague

>What is that mysterious dark energy or matter surrounding us?
A placeholder theory until we can explain the effects of the universe that brought about the theory.

>Could it be the presence of God...?
It could be anything, though the "presence of God" tends to be an explanation that halts scientific discovery and understanding.

>How do we know dark matter exists if we do not have any way to measure it?
We do have a way to measure it. Measure the matter that we can measure and if the result isn't enough to create cohesion, there must be matter that we can't see. That's the whole idea behind dark matter. Astrophysicists realized that there isn't enough visible matter to to hold the galaxies together. The estimated amount of gravity simply couldn't be created by that small amount to keep a galaxy from falling apart. So some genius (note the sarcasm) filled in the missing matter with something that can't be seen or measured, creatively calling it dark matter.

Similarly, dark energy is the result of measuring the expansion of the universe and trying to explain why it's increasing rather than slowing down or remaining the same.

>maybe this dark matter somehow cancels true matter..
Well first, dark matter couldn't be antimatter because it's visible matter that we can measure. Second, if dark matter canceled true matter, that would kind of defeat the purpose of dark matter which is to fill in the …

WolfPack commented: Interesting point of view +8
Narue 5,707 Bad Cop Team Colleague

>a vector cannot be used as the container to be adapted for a std::queue;
>the container needs to support push_back and a pop_front.
Try reading for comprehension next time. That was an either/or statement. You can use the stack and queue adapters OR vector and deque because the adapters are notoriously inflexible in practice. Of course, you could play games with me about using stacks to simulate a queue and queues to simulate a stack if you want to try to recover from your mistake, but that would be reaching.

>using a vector to implement a queue would not be a good idea (performance).
You're not very creative, are you? Just because push_front and pop_front aren't available to a vector doesn't mean you can't achieve the correct functionality of a queue in an efficient manner.