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

I ask that question you to ask from yourself. You knew the correct answer.

The correct answer is apparently what you want it to be, not what others think. When I go to the supermarket to buy food, I don't give it a second though how the meat was killed and processed. Animals are born to be eaten by either humans or other animals -- that's just a fact of nature. If you want to see cruelty in nature just watch some of the nature films that show how a lion kills their food, or how an alligator eats other animals (sometimes small human children) alive.

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

I don't know where or when that video was filmed, but here in USA we have an Animal Humane Society that trys to put a stop to animal cruelty, this is a recent article

I was raised on a single family-owned farm from 1950-1962 and I can attest that we did not treat our animals like they do in that film. Our chickens were allowed a lot of freedom outside the chicken coop. And our cows and hogs were treated with a great deal of humanity, never allowed to go hungry or thirst, and they too had lots of space to roam. I frequently drive through the countryside to and from work and see that same sort of behavior from today's farmers.
[img]http://comps.fotosearch.com/bigcomps/BNS/BNS415/bn329024.jpg[/img]

And this is some pictures that illustrate how we raised our chickens.

I'm not saying all American's are like that. We do have chicken farms and hog farms.

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

all you have to do is typecast the character to int cout << 'A' << " = " << (int)'A' << "\n"; or

char a = 'A';
cout << a << " = " << (int)a << "\n";
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Eating animal flesh is just a survival method of most animals. The lion in the wild will hunt down, kill and eat almost anything. And humans are no different -- except some humans kill just for the sport of it.

Today I am eating ham for dinner, as is the custom of most other Americans.

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

config files have a general format as <tab name>=<value> What that program is doing is finding specific tag names and, if found, reading the value field.

Line 26 is a loop that reads all the lines in the file. Then 28-35 check for specific tag name and, when found, reads the value field of the line.

If you are still confused then compile the program for debug and use your compiler's debugger to single step through the program, then inspect the value of the variables to see what the program did.

kelechi96 commented: Thank You +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>No consensus?
Yes, I'm right and everyone else is wrong :) Its not a matter of majority opinion -- I already explained with example whay feof() doesn't work as a loop control. Take it or leave it.

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

Happy Easter everyone, even to those of you who are not Christian. I worked last night at Wal-Mart and I can tell you we sold out of almost everything eatable -- was almost like Christmas. 10:00 p.m. and there were very very long lines. But that's not the point of this thread -- just

http://i.flowgo.com/greetings/rapeasterbunny/rapeasterbunny.swf

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

human race won't die as long as there are males

what about nuclear war??? Or an huge asteroid hitting Earth ?? Or little green monsters from Mars ???

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

its a poorly written program.

>>istringstream sin(line.substr(line.find("=") + 1));
The program will more than likely crash if line does not contain '=' or if that symbol is the last character on the line.

>>if (line.find("num") != -1)
line.find() doesn't return -1, it returns string::npos.

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

>>can anyone help me
Can we? Yes. Will we is another question. We are not going to do your homework for you. Use google and you will probably find what you are looking for (the code).

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

No matter how you cut it, the loop

while( !feof(file) )
{
   // blabla
}

will make the program read the last line (fgets()), last character (fgetc()) or last read (fread()) appear to be read twice, as I proved in my previous post. That's why such a loop is poor coding and will cause problems.

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

I think happygeek should change his name to happysuit. And dani should be happyhoe.

In USA a hoe is a slang word for whore. So are you calling Dani that?

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

Don't know the first thing about either one, so I won't vote :)

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

What I have sometimes done is make the first parameter a static method then make the third parameter (arglist) the this pointer of the class instance. That way the thread can access the public objects of the class.

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

The first parameter must be either a static method of a class or a global function. You can't pass class methods unless they are declared static.

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

namespace mynamespace
{
    int x=0;
}

Don't put that in a header file because you will get duplicate declaration error messages!

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

you might try the suggestion in this thread

Move your files/projects from //c:\Documents and Settings\Matias Moisio\Työpöytä\Projects\ to a much shorter path. I like to put all projects in c:\dvlp because that's a lot easier to type!

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

i guess u are code into a project that u've already compile and use.try to open another project and compile.

That makes no sense at all -- and please type you instead of u; its only two more key strokes

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

What a crap this code is ?
60% of your code is full of bugs ...

Read your textbook first !

By the way, in future post using code tags ...

Looks a lot like my code too :)

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

Welcome to DaniWeb.

I always found the concrete patio outside my backdoor an excellent way to repair computers.

  1. Open Door
  2. Toss Computer Out
  3. Watch it splatter all over the concrete.
  4. Sweep up the rubbish
  5. Deposit in trash can
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The number of folks in US prisons is about 2% of the number of employed folks. However, minorities have been particularly affected: One in nine black men ages 20 to 34 is behind bars.

That's not true -- people in prisons are not counted as either employed or unemployes. They are non-people.

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

If you have a static variable in each of those two classes then they will be distinctly different variables.

class A
{
public:
    static int x;
};

class B
{
public:
    static int x;
};

A::x and B::x are two different variables

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

why not something like cc -o a.out obfile.o -lmylib.a

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

using a loop such as

while( file.eof() )
{
   
}

will cause problems on the last line -- such a loop will read the last line twice and whatever code you have inside { and } will get executed twice on eof. That's why fgets() works better as loop controller because it returns NULL when eof has reached.

To demonstrate that problem, compile and run the program below

#include <stdio.h>
#pragma warning(disable: 4996)

int main()
{
    FILE* fp = fopen("ReadMe.txt", "r");
    char line[255];
    int counter = 0;
    if( fp != NULL)
    {
        
        while( !feof(fp) )
        {
            counter++;
            fgets(line, sizeof(line), fp);
            printf("%d: %s", counter, line);
        }
        fclose(fp);
    }
}

And below is the output -- notice the last line appears twice (lines 33 and 34 are the same line in the file)

15: Application Wizard.
16:
17: test7.cpp
18: This is the main application source file.
19:
20: ////////////////////////////////////////////////////////////////////////////
/
21: Other standard files:
22:
23: StdAfx.h, StdAfx.cpp
24: These files are used to build a precompiled header (PCH) file
25: named test7.pch and a precompiled types file named StdAfx.obj.
26:
27: ////////////////////////////////////////////////////////////////////////////
/
28: Other notes:
29:
30: AppWizard uses "TODO:" comments to indicate parts of the source code you
31: should add to or customize.
32:
33: ////////////////////////////////////////////////////////////////////////////
/
34: ////////////////////////////////////////////////////////////////////////////
/
Press any key to continue . . .

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

you have to change line 4 too :)

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

>>void Keyboard(int *pNum, int *pCount)

You need to pass those pointers by value so that Keyboard() function can change them, like this: void Keyboard(int **pNum, int **pCount) Then from main Keyboard( &pNum, &pCount); Then in Keybord() when you reference pNum you have to use *pNum. Same with pCount.

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

>>i can sleep..so stress..now it around 3am at Malaysia.
Get some sleep -- the solution will be clearer in the morning.

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

using fgets() would make the program a lot simpler. When this loop finished it will have read the last line of the file.

while( fgets( string, sizeof(string), file) )
{
   // do nothing here
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

People here generally ignore threads marked Urgent.

>>Can someone "genius" help me to complete this.
What parts do you have problems implementing?

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

check and recheck file name spelling.

Create a command prompt, cd to the directory in which the file exists, then type dir Proj4_input.txt <Enter> to see what comes up.

Use Windows Explorer to search for the file.

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

>>The code is not able to open the input file.
Obvious answer -- the input file doesn't exist or is not where you think it is.

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

Huh? The very first line says Posts: 750

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

>>Does variables in a namespace behaves like a static variable where it will keep the most recent value?

No. static variable may appear either inside a class or outside any class.

  • When static variables are part of a class then they require class scoping, such as MyClass::MyVariable = 0; They must also be declared globally just like any other global variable with the class scope just as in the previous example.
  • When static variables are declared globally (not inside a class) then they are in global namespace unless you put a namespace around them.
namespace mynamespace
{
    int MyGlobal = 0;
}

Functions and methods can also be declared static.

tux4life commented: I let that question open for you :P +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you need to pass the string by reference. in GetArray() the string is local to the function so when the function returns the string is destroyed, invalidating the return pointer. const char* getArray(string& s){ Actually the function doesn't need the temp pointer at all.

const char* getArray(string& s)
{
    return s.c_str();
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>I would say that they are at least 50% unemployed.
Sorry, but it doesn't work that way. And that is one reason why I think all companies should be required to provide health insurance for all their employees.

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

>You should have gotten a DaniWeb t-shirt!
I'm sure if you visit Daniweb's office, you can get a business card or something. ;)

Actually that's not that bad of an idea :icon_idea: If we ask her very nicely maybe she will email us all her business card :)

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

>>Another number also considers people who are stuck in a low paying or a partime job.
They are NOT unemployed! How can you possibly be considered unployed if you have a job and get a paycheck?

There are many unemployed people who are not counted in the unemployment rate. The Bureau of US Statistics does not count every enemployed person, but just takes a sample every month.
The Bureau of US Statistics

Who is counted as unemployed?
Persons are classified as unemployed if they do not have a job, have actively looked for work in the prior 4 weeks, and are currently available for work. Actively looking for work may consist of any of the following activities:

  • Contacting:
    • An employer directly or having a job interview
    • A public or private employment agency Friends or relatives
    • A school or university employment center
  • Sending out resumes or filling out applications
  • Placing or answering advertisements
  • Checking union or professional registers
  • Some other means of active job search
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

yes

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

Forget vb version 6 -- its obsolete because vb.net replaced it.

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

why are you opening the text files in binary mode??? Just open it in text mode

// not that ios::in and ios::out flags are not needed for ifstream and
// ofstream
ifstream infile (ascifile); 
ofstream outfile( binfile );
while( infile >> Index1 >> Index2 >> simvalue )
{
    outfile.write((char *)&Index1, sizeof(Index1);
    outfile.write((char *)&Index2, sizeof(Index2);
    outfile.write((char *)&simvalue, sizeof(simvalue);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

After line 19 you need to flush the input buffer of the '\n' character. cin.ignore(1000,'\n'); should do the trick.

hurbano commented: very helpful +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The "download" link somehow added backslashes before every single and double-quote.

Which is yet another reason to just simply post your code here.

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

Oh, so the user can enter a complete sentence as the command-line arguments.

std::string sentence;
int nc = 1;
if( argc > 1 && strcmp(argv[1], "-d") == 0)
{
     info = argv[2];
     nc = 3;
}
while(nc < argc)
{
    sentence += argv[nc];
    sentence += " ";
    ++nc;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what are the erotic fantasies ?

Google for it. Links to them are not permitted here at DaniWeb and you will get infracted for posting them.

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

>>this post is not about telling you not to use C++ preprocessor
Good, because it is not possible.


>>How to generate the preprocessed file . well GCC you can , but MS VC++ I even yet don't know.

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

The same thing that happened when you reached 700 posts. Nothing. When you reach 1,000 you will get one of those yellow stars :)

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

line 13: >>if((argc > 1)&& !strcmp(argv[1], "-d") && (argc > 2))

All you need is one check for argc if((argc > 2)&& !strcmp(argv[1], "-d")) Also post a few lines from the text file.

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

>> input.open(\"data.txt\");

That should be input.open("data.txt"); -- remove the '\' characters because the quotes are not part of the filename.

You also need to delete the '\' characters every where else you want to print or use quoted text (strings). That character is called an escape character. Your compiler should have produced lots of errors throughout the code because of those escape '\' characters.

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

>>i didn't want to spam the message board.
You won't. Just past the code between code tags and you will be all right. We can't copy from that link into our compiler's IDE.

[edit]Ok, so I didn't see the Download button at the bottom of the page :) [/edit]