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


Bug I ma getting is thses error which i am not able to solve out. Can anyone help me.

thsnks.

What are the error message(s)?

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

Huh? Just sum up the clock cycles you posted, but that does not include the time printf() function takes.

If you want a better way to profile your program, use clock() function which return time_t object

int main()
{
    clock_t t1, t2;
    t1 = clock();
    // put your code here

    t2 = clock();
    printf("Diff = %d\n", t2 - t1);
}

Depending on your program you might see that t1 and t2 are the same time, meaning your program ran too quickly to be measurable. Many programmers will repeat the code several times (or millions of times) in between t1 and t2 in order to get measurable time.

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

Is it possible (using VC++6) ...?

Get a newer compiler. You can download free Microsoft VC++ 2008 Express, but it doesn't do MFC. But it is a lot more compliant with c++ standards than 6.0 version.

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

my guess is that the code you want is in the folder fruit -- it has a board.cpp and board.h which might contain relevant information.

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

In addition to the list of recent posts it would be helpful to also include the forum that the post was made in, there is plenty of room below the time for that.

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

how about using a function (Warning! not compiled or tested.)

bool IsInArray(const char array[], int size, const char* search)
{
    bool found = true;
    for(int i = 0; i < size; i++)
    {
        if( strcmp( array[i], search) == 0)
        {
             found = true;
             break;
        }
   }
   return found;
}

int main()
{
    char* a[] = {"abc", "def", "ghi"};
    char* b[] = {"abc", "def"};

   for(int i = 0; i < 3; i++)
   {
       if( IsInArray(b, 2, a[i] )
          cout << a[i] << "\n";
   }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You will have to post the code you started because my eyesight isn't good enough to see your monitor.

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

I might be possible, but I don't know what source files to include in the project. If you can get the *.dsw file or a makefile (usually has *.mak file extension) that would be great. The *.exe file is useless for this purpose.

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

its not possible to typecast a va_list object into an int* pointer. What you will have to do is create an int array, loop through the va_list and then pass the array to the function. google for va_list to get examples of looping through the list.

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

>>please make it snapy
That little remark will certainly get your thread ignored by everyone, including me. Your deadline is not our problem.

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

The source does not include the *.dsw file for use by VC++ 6.0 IDE. And next time you zip up source code you should delete all the files that are generated by the compiler, such as all the *.obj files. That will make the zip file smaller.

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

I have 64-bit Vista Home Prem and was using IE7, which is the default for Vista. But it had problems locking up while surfing the web, so I installed Firefox (32-bit version). I have not had any problems at all with it. I'm now installing AdBlock Plus per your recommendation.

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

>>I think the problem is I am adding it to a Vector of StaffMember objects. Staff Member is the base class, so would case the derived classes into StaffMember objects?

Simple:

#include <iostream>
#include <vector>
using namespace std;

class Base
{
public:
    Base() {x = 0;}
    virtual void Display()= 0;
protected:
    int x;
};

class Derived1 : public Base
{
public:
    Derived1() { x = 1;}
    virtual void Display() { cout << "This is Derived1\n";}
};

class Derived2 : public Base
{
public:
    Derived2() {x = 2;}
    virtual void Display() { cout << "This is Derived2\n";}
};

int main () {
    vector<Base*> theList;
    Derived1 * pD1 = new Derived1;
    theList.push_back(pD1);
    Derived2 * pD2 = new Derived2;
    theList.push_back(pD2);

    vector<Base*>::iterator it;
    for( it = theList.begin(); it != theList.end(); it++)
       (*it)->Display();

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

I agree that mine looks a lot better now. I was hoping Dani would fix it so that it looked similar to everyone else.

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

>>DWT 5/3 and 9/7.
I have no clue what that is :)

Maybe you should ask that question in their newsgroup

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

Nic: you answered a 4-year-old thread! The op has probably died of old age by now.

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

just do this: char* res_name . But, the trick is that space needs to be allocated before it can be used the first time, such as res_name = malloc(25); initialize it in the do loop

do
{
printf("\nEnter %d res_type:",i+1);
res[i].res_type = malloc(25);
scanf("%d",&res[i].res_type);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

wurreckt: Everyone agrees the cop was an idiot and should probably get canned for that incident. The question was whether or not it was racially motivated -- there was nothing in the article to indicate it was. But on the otherhand, what is NOT said is just as important as what is said.

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

narrow it down for us by posting only what you tried to do but failed. I don't have the time to read that entire program to figure out what you are talking about.

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

did you try this: double bat::travel_time (double distance, terrain_type t)

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

I watched this on tv just awhile ago and it blows the current global warming theory out of the water! At one point in Earth's history the planet was just one big snowball with volcanoes pumping billions/trillions of carbon dioxide into the atmosphere. Because there was no rain to cleans the atmosphere the Earth's average temperature rose to over 120 degrees F, causing all the ice to melt, clouds formed, and the rains came to clean the air.

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

line 20: you need to use two '\' folder separator characters so that the compiler doesn't treat them as escape characters spInventRep = fopen("C:\\Users\\Jenniy\\Desktop\\ch 7\\inventory09.txt", "r"); line 22: you can not use the same FILE pointer for both input and output files -- use two different names.

line 36: use the == boolean operator, not the = assignment operator

line 37: remove the & pointer operator -- just do a normal assignment here price=1.23; Same thing on line 39-45.

It would help if you would post a few lines of the input data file.

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

Or instead of uploading to another server you can just attach them to your post here. Click on "Go Advanced" button at the bottom of the screen, then "Manage Attachments" button. Note: you will probably have to zip up the *.html file before attaching.

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

Yup, mine is history too.

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

The only mobile applications I have written are in c++ and run on a barcode scanner handheld computer from Symbols Technologies. The program was written in c++ using Microsoft Visual C++ 2005 and Mobile 5.0 operating system on the scanner. But for you to do something like that would cost you an investment of about $3,000.00+ USD.

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

Get input as a string, not an int, so that the loop can easily test for on-numeric characters and act accordingly.

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

1. Next time use code tag with the language specifier:
[code=c++] source(s)

[/code]

c++ has been depreciated. use [code=cplusplus]

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

>>don't think you can't assign values to functions/methods.
That is how to create a pure virtual function

A pure virtual function or pure virtual method is a virtual function that is required to be implemented by a derived class that is not abstract. Classes containing pure virtual methods are termed "abstract;" they cannot be instantiated directly, and a subclass of an abstract class can only be instantiated directly if all inherited pure virtual methods have been implemented by that class or a parent class. Pure virtual methods typically have a declaration (signature) and no definition (implementation) .

eduardocoelho: you need to declare the implementation of a virtual function exactly as it is in the base class, but without the "=0". The simplest way to get this right is to just copy/paste from base class to derived class.

#include "AbstractObserver.h"
#include "IupDialogWrapper.h"

class IMDialog : public AbstractObserver, public IupDialogWrapper {
public:
	virtual void update(int progressStatus) {
		cout << "IMDialog: " << progressStatus << endl;
	}

       // another methods of the IupDialogWrapper class..
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I'm not sure what you are asking. Do you need to save the ages for later? If not, then you don't need arrays

ifstream in("filename.txt");
std::string name;
std::string grade;
int age;
while( in >> name >> grade >> age )
{
   if(age > 50)
      cout << "Group 4";
   else if( age > 40)
      cout << "Group 3";
  // etc etc
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Is this safe to assume its the same on all c++ compilers?
No. See limits.h for size limitations.

>>Why does 'printf("size of size_t: %d\n",sizeof(size_t ));' make a warning?

Probably because size_t is unsigned long and %d is signed int. Try %u and see if the warning persists.

>>The size_t is a unsigned long int, so apparantly it uses 8 bytes,
No, its only 4 bytes on a 32-bit compiler. See the sizeof operator.

>>It seems that the max value of a size_t on my 64bit ubuntu system is
18446744073709551615

It's the compiler's limits in limits.h. If you are using a 32-bit compiler than the size of size_t is still 32-bits even though you may be running the compiler on a 64-bit operating system.

Considering the output you received from your program I would guess that g++ is compiling as a 64-bit compiler.

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

>>but I haven't the faintest clue what class base& b= d; means

It means b is a reference to d -- in otherwords both b and d are two different names for the same object.

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

# The world's fastest speeding ticket allegedly was issued in 2003 in Texas, when the driver of a Swedish-built Koenigsegg went 242 mph in a 75 mph zone.

Wow! I wonder how he got caught?

As for your original post -- you are insisting that the incident was racially based? I didn't see that in the article, so you might be jumping to conclusions there. But I agree that the cop should be fired for being so insensitive.

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

This is c++, not C, so just use the std::string + operator to concantinate strings

std::string areaCode = "999";
std::string prefix = "555";
std::string number = "1212";

std::string result = areaCode + " " + prefix + "-" + number;

If you have to use character arrays then use strcat() to concantinate the strings

char areaCode[] = "999";
char prefix[] = "555";
char number[] = "1212";
char result[126] = {0};
strcat(result, areaCode);
strcat(result," ");
strcat(result, previx);
strcat(result,"-");
strcat(result, number);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

basicly my point being i wrote the program but the gui doesn't take event in the middle of my loop or in other words i want it to run in the background so i can do my other stuff in meanwhile also

You need multiple threads to accomplish that. Create a worker thread that does the counting so that the main thread can continue doing whatever needs to be done.

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

Depends on the c++ class. If the queue object is protected or private, then I'm afraid not.

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

This works great for me, using VC++ 2008 Express

#include "stdafx.h"
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main(int argc, char* argv[])
{
        std::vector<int> truth_table;
        std::vector<vector<int> > truth_table_col;

        double no_of_twos = 7;
        double base_two = 2;
        
        cout << "No of 2's = " << no_of_twos << "\n";
        double combi = pow(base_two,no_of_twos)-1;

        for(int hfh=0; hfh<=(int)combi; hfh++)
        {
                for(int ghg=0; ghg<=(int)no_of_twos; ghg++)
                {
                        truth_table.push_back(0);
                }
                truth_table_col.push_back(truth_table);
                truth_table.clear();
        }
        for(size_t i = 0; i < truth_table_col.size(); i++)
        {
            vector<int> &table = truth_table_col[i];
            for(size_t j = 0; j < table.size(); j++)
                cout << table[j] << " ";
            cout << "\n";
        }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The reason it closes is because cin left the Enter key '\n' in the keyboard buffer, and the next cin.get() just removed it. To fix this problem you need to flush the keyboard buffer after entering numeric data. One way to do that is call ignore(). See Narue's article in the c++ forum stick post about details of how to flush the input keyboard buffer.

cin >> price;
cin.ignore(); // flush '\n'
Intrade commented: It's nice to know you're still at it, helping people =) +1
tux4life commented: Very well explained ! +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>I forgot how to make it so when i type something and press enter, it displays what i wanted it to.

use cin to get keyboard input

int price;
cout << "Enter price of house\n";
cin >> price;
cout << "The price you entered is " << price << "\n";
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

In C languge you do not use the c++ reference & operator, but pointers

void join(queue *q,int elem)
{
        q->items[q->rear]=elem;
        q->rear++;
}

And invoke it like this: join( &que_write,1);

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

I just read that Dani was doing some server maintenance this morning -- that might have temporarily caused the problem.

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

you can't do 2d arrays like that

char **array = new char*[x];
for(int i = 0; i < x; i++)
    array[i] = new char[y];

Then you destroy it like above, but in reverse order.

I have seen another way to do it, but I never bothered to get the hang of it :)

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

Is this supposed to be C, not C++? I question this because of int isempty(queue &q) -- the parameter looks like a c++ reference.

Is that supposed to be circular queue where the front and back variables wrap around to 0 then the buffer items is filled up? If yes or no you need to add code to the join() function to wrap the front variable when it reached MAX, or not allow any more items in the queue when (front+1) > rear.

You need to firm up your understanding of the front and back variables.
front: This is where the next item will be inserted into the queue. When an item is inserted (see join function) this is the variable that should get incremented.

rear: This is where the next item will be removed from the queue. When an item is removed from the queue (see leave function) this is the variable that will be incremented.

You need checks in join() that front+1 does not exceed rear. And you need checks in leave() that rear+1 does not exceed front.

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

Well by writing ne instead of any doesnt show any kind of sloppiness by any means . both the word sound the same so its easier to write thats it .

We discourage the use of leek, or chatroom, speak here because there are a lot of members whose mother toung is not English. Consequently they may have no clue what ne means. Just because it may sound the same to you doesn't mean it sounds like that to everyone else. And "its easier to write" doesn't cut it either -- only one key stroke -- surly you can not be that lazy!!

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

As Narue said, using externs can become a real nightmare for program maintenance by either you or someone else. I recall some 20+ years ago I was hired onto a new job and someone had written a C program that was about 15-20 *.c files, each file declared several global variabls which were declared extern in each of the other files that referenced them. What a nightmare that was to figure out what was declared where -- and sometimes they were declared globally in more than one *.cpp file! Finally I moved all the globals into just one file named globals.c and all the extern statements into one *.h file named externs.h. It took a week to get all that mess straightened out.

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

It's not possible. But you might put the managed code in a dll or static library.

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

I thought about getch(), but he is using a c++ compiler so cin.get() is most appropriate -- and it's standard to boot!

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

One program -- one computer -- one CPU. One program can not run across multiple computers like you describe. If the computer has multiple cores then the operating system might distribute the threads among the cores, but it will not distribute threads across computers. There might be special add-on kernel-level software that will facilitate that, but its not a native feature of most computers.

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

add something to the end of the program that makes you enter a key, such as cin.get() -- btw the problem is your program, not the IDE.