Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

yea, there were a couple typing errors which you will have to correct before compiling that code. I've corrected them in my previous post.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you need to use std::stringstream class. It is very similar to fstream but ccreates the result in memory instead of in a disk file.

#include <sstream>
#include <string>
using namespace std;

int main()
{
    int a = 4, b = 5, c = 6;
    string d;
    stringstream str;
    str << a << " Hello " << b << " bye " << c;
    d = str.str();
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

when do you mean buy "why won't it work ...". Do you take your car to the auto repair shop and tell them "its broke -- pleas fix it." ? We need a lot more information.

In the code you posted, line 6 is returning the 6th element of the array, but line 8 only allocates an array with 3 elements.

CPPRULZ commented: it was true and helpful +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 8 belongs up between lines 2 and 3. The using statement should appear immediately following all includes and before any functions.

line 7: you can't declare arrays without the dimensions.

line 12: you have to pass an array. You call it like this:

int arr[10]; // an array with 10 elements

fund( arr );  // pass array to the function
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Check to see if the number is already in the list before adding it. The delete() function is not the place to do that. Write another class method that does nothing but search the list for a number, return true if the number already exists in the list or false if it doesn't. Then if it doesn't call that Insert() function.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The problem is in main(), not that delete function. First it calls insert to insert a new number then turns right around and deletes it. Delete that line

while(inFile>>number.item)
{
	display.Insert(number.item);
	//display.Delete(number.item);  <<<<< delete this line
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

why is that function not returning the mean ? You don't need that last parametewr

double meanOf3(double value1, double value2, double value3)
{
	return  (value1 + value2 + value3)/3;
}

int main()
{
    <snip>
    double mean = meanOf3(value1, value2, value3);

}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I know that -- but post an example of the string -- such as "Hello World".

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here's the result I get

The numbers that are divisible by 5 are
0, 5, 10, 15, 20
25, 30, 35, 40, 45
50, 55, 60, 65, 70
75, 80, 85, 90, 95
100, Press any key to continue . . .
#include <iostream>
using namespace std;

int main()
{
int minrange = 0;
int maxrange = 100;
int increment = 5;
int count = 0;
int sum1 = 0;
if(minrange<maxrange)
{
    cout <<"The numbers that are divisible by " <<increment<<" are ";
    cout <<endl;
    int num_printed = 0;
    for(count=minrange; count<=maxrange; count++)
    {
          if(count%increment==0)
          {             
             cout <<count;
             num_printed++;
             if(num_printed < 5)
                cout << ", ";
             else
             {
                 cout << "\n";
                 num_printed = 0;
              }
             
             sum1 = sum1+count;
          }
    }
}
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yes I noticed that you changed the first parameter from xx to moves[0]. So what does moves[0] contain anyway?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

post new code.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

In the code snippet you posted above, what string does xx contain? There is probably another way to do what you want without using sscanf(). Post an example of moves[0]

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Note that sscanf isn't an ordinary method or built-in function, but a very special construction in Pike.

That link is not talking about C or C++ languages.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what's your question about queues ? Don't just post code and expect us to guess what you want.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

sscanf() is a C function, not c++, and knows nothing about c++ containers like std::string, you have to pass it a character array. sscanf(xx.c_str(), "%c%c %c%c", &fromX, &fromY, &toX, &toY);

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
if(minrange<maxrange)
{
    cout <<"The numbers that are divisible by " <<increment<<" are ";
    cout <<endl;
    int num_printed = 0;
    for(count=minrange; count<=maxrange; count++)
    {
          if(count%increment==0)
          {             
             cout <<count;
             num_printer++;
             if(num_printed < 5)
                cout ", ";
             else
             {
                 cout "\n";
                 num_printed = 0;
              }
             
             sum1 = sum1+count;
          }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Its done something like this: Note: not compiled or tested.

node* temp=start_ptr;
node* prev = NULL;
while( temp )
{
   if( temp->item == item) 
   {
          // delete this node
         if( prev == NULL)
         {
            // we are at the head of the linked list, for remove the head
            start_ptr = start_ptr->nxt;
         }
         else
         {
               // we're somewhere in the middle of the linked list
               prev->nxt = temp->nxt;
        }
        delete temp;
        break; // all done
   }
   prev = hold;
    hold = hold->next;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Put another if condition that test count % 5 == 0

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I have seen sites that will write people's homework for $$$. But DaniWeb is not one of them :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The mountain I am talking about is that the armed forces are not trained in the concepts of law enforcement - this is not derogatory. The armed forces are trained to defend, attack, and contain; there is no real overlap nor should there be. If 2 police officers heard a bullet whiz by their heads, they would look for the source of and, if possible, talk to the person who fired at them, get them to disarm and take them into custody (ideally). If 2 Marines are fired on, they would track the person to his home and kill him. This is why we do not want the armed forces to perform the duties of law enforcement.

Does this make some sense?

I do agree that the armed forces are not trained to be policemen and should not normally be put into that capacity. But when put into that situation I doubt anyone would perform as you indicated (track down the shooter and kill him). Do you really think members of the armed forces are that stupid? When LBJ used them to quiet down the school desegregation riots, how many military tracked down the rioters to their homes and shot them? Answer: zero.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
while (nodePtr->pointer != a)
    {
       nodePtr = nodePtr->next;
    }

What happens when thre are no nodes whose value is equal to variable a? Answer: infinite loop that will eventually crash your program. That loop needs to also check for end-of-linked-list, which is normally indicated by NULL nodePtr

while ( (nodePtr != NULL) & (nodePtr->pointer != a) )
    {
       nodePtr = nodePtr->next;
    }

What kind of object is nodePtr->pointer ? Is it a pointer to something? If it is, it can't normally be compared to an integer.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

To convert an ascii digit to numeris, all you have to do is subtract '0'. Here's one way to do it. Note that getchar() returns an int, not char.

int a = -1, b = -1;
int input.
while( (input = getchar()) != EOF)
{
    if( isdigit(a) )
    {
         if( a == -1)     
        {
            a = input - '0'; // convert input to binary digit
        }
        else
        {
            b = input - '0'; // convert input to binary digit
        }
        if( a > -1 && b > -1)
        {
            cout<< "a " <<a << " b" << b <<endl;
            a = -1, b = -1;
       }
   } // end if( isdigit() )
} // end while loop
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Probably Microsoft Web Developer 2008 Express

You should also read this thread, and the threads on the Web Developer's boards.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That's not talking about freedom -- its referring to stopping terrorists, unless of course you think terrorists should be free to use WMD anytime and anyplace they wish.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I'm a newbe at this so started the walkthrough. I'm really confused about one statement

http://msdn.microsoft.com/en-us/library/k4cbh4dh.aspx

Adding and Programming Controls
<snip>
To Set Control Properties
<snip>
3. Put the insertion point in a space within the <asp:label> tag, and then press SPACEBAR.
A drop-down list appears that displays the list of properties you can set for a Label control

What is an "Insertion Point" they mention? I've tried putting the mouse cursor ther and pressing the space bar, but that isn't it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

this is a pointer, *this dereferences the pointer. So if you want to pass a pointer just don't use the asterisk. myFunction(this, &copyClass); That doesn't mean it will solve your problem, but that's how to pass pointers.

That looks like a recursive function call, I doubt you even need to pass this pointer because the compiler will do that anyway.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>>can you help?
No -- I have no clue what that program is supposed to do. Don't expect me to read your other threads -- a thread should stand on its own.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Welcome to DanWeb.

>>No jokes about my age, PLEASE!
Naaaw. There are several other members including myself who are probably older. We don't discriminate on ancient technology or people :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you are making a mountain out of a molehill. The President is allowed to use military force when requested by state governors or when the state is unable or unwilling to to protect civil rights and property. I believe LBJ used that authority in the 1960s to assist school desegregation.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Miss Palin

She's not a Miss. Its either Mrs (because she's married) or Ms (because shes a woman's libber).

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>if(people.lastname == lastname)
You can't compare two character arrays with the == operator like you do two std::strings. To compare character arrays call strcmp() functions. if( strcmp(people[i].lastname == lastname) == 0)

stilllearning commented: yup, I just realized that myself +2
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If Americans votes for cuteness then John Edwards would have been the nominee with his $500.00 USD haircuts.

utube I Feel Pretty

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You posted your assignment, now what do you parts don't you understand.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

ditch that compiler because it doesn't implement c++ very well. Better to get newest free Visual C++ 2008 Express -- you can download it free from Microsoft.

>>because i tried to use visual C++ 6.0 at windows vista
That's not the problem -- the problem is the compiler itself.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Hello,
I am little bit confuse for c and c++. All loops are same in both the languages so why they are different for each other?

you will find the same similarities in most computer languages and that makes it easy to learn several different languages.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

probably something else wrong with your program because this one compiles ok. using std::vector::iterator -- no such thing.

#include <string>
#include <vector>
using std::vector;

using std::string;

int main()
{
    vector<string> v;
    vector<string>::iterator it;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You first need to learn how to format your code -- what you posted is a huge mess which I refuse to even try to read.

delete use of conio.h and studio.h -- this is a c++ program, not C.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

unistd.h is a *nix-specific file and not supported by Microsoft compilers. I think Dev-C++ might support it though on Microsoft platform. More links about that here.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

My guess is that you forgot to include <vector> and/or using std::vector; statement

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Since you have the coice of entering either last name, or first and last name, you will probably have to ask for which they want to enter then create an if condition
Example:

...
int type;
char firstname[20] = {0};
char lastname[20] = {0};

cout << "Enter 1) Last Name\n2) First Name and Last Name\n";
cin >> type;
if( type == 1)
{
    // last name only
    cout << "Enter Last Name\n";
    cin >> lastname;
    // now search the array for last name only
}
else if( type == 2)
{
    cout << "Enter First Name\n";
    cin >> firstname;
    cout << "Enter Last Name\n";
    cin >> lastname;
   // now search the array for both first name and last name
}
else
{
    // display error message
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You can only specify one type of loop counter.

>>Is this just a bug in the Visual C++ compiler
Not a bug. That type a statement is never allowed

int a, int b; // error
int a,b; // ok
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The debate's over now, I thought Sarah did a lot better than most people throught she would. To my knowledge neither of them made any major gaffs.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Homework -- we don't do people's homework. You write and ask questions -- we answer them.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I hope Sarah does well tonight -- I don't like seeing girls cry.

Aside: As you all know (or should know) I'm from St Louis area where the debate is going to be held in an hour or so. The city is filled with cops from all over the state and secret servicement. Today, someone robbed a bank in St Louis, escaped the cops around the back, then ran smap dab into a bunch of secret servicemen :) At least that's the story I heard on our local talk radio today.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You mean you can't read minds?

DaniWeb newbes have asked me to do that lots of times, but I don't have a crystal ball nor is my eyesight good enough to see their monitors from where I am sitting.

R0bb0b commented: indeed +2
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what do you mean by "create the makefiles for each os"? sorry, I'm a bit of a noob :/

I did:

#include <iostream>
using std::cout;
using std::cin;
using std::endl;

void clearScreen()
{
	#ifdef _WIN32
	system("cls");
	#elif defined(_UNIX)
	system("clear");
	#endif
}

int main()
{
	cout << "coco" << endl;
	cin.get();
	clearScreen();
	cout << "coco2" << endl;
}

and the result:

omc@linus-marx:~$ /home/omc/workspace/LigaSagres/Debug/LigaSagres
coco

coco2
omc@linus-marx:~$

so it didn't work. I guess maybe because I have not created "the makefiles for each os"

What do you mean by "it didn't work" ? I don't know what that stuff is that you posted.

"makefile for each os" means that you have to compile your program in each os -- once under *nix and again under MS-Windows. You can't compile once and run on both operating systems -- that won't work.

If you use g++ compiler then you can probably have one source file and use the same compiler on both os. You will need a version of g++ for unix and another version of g++ for MS-Windows.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Well i dont see your website link i think it has been removed can pm me the url?

Your signature: Don't you read the blogs on your own web site?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I don't understand. What you asked is what I posted. cin is used to read from the keyboard.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 17: doesn't make any sense. You might as well just delete that line.

line 25: you can't copy character arrays like that. Either (1) make name_sel a pointer, then line 25 will work, or (2) call strcpy() to copy the two strings.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
char value;
cout << "Enter a letter\n";
cin >> value;
if( value == 'a' || value == 'A')
{
    // do something
}