DeanMSands3 69 Junior Poster

In the output scenarios you use printf("%02d = %02d:%02d am\r\n", i, First, Last);
Each %02d tells the compiler you want a two-digit number with leading zeroes.
However, the first %02d in each output line should be %04d since we want a number 4-digits long with leading zeroes.
Try that instead.

Three words on coding style for beginners: (if you believe ignorance is bliss please disregard)

  1. main should always be declared as a int instead of a void. Assuming no errors, return 0; at the end is fine.
  2. getch(); and also system("pause"); at the end of a program are bad form and you'll want to break that habit early on. Put in the return value at the end of main and, once you've learned to use the debugger, set a breakpoint there. This keeps your window open until you're done with it.
  3. Using #include<conio> makes your code "non-portable" (i.e. could break this code on another C compiler on another platform) and is discouraged. Getting rid of the getch(); means you can get rid of #include<conio> .

But most importantly, good luck and have fun coding.

DeanMSands3 69 Junior Poster

You've got some parenthesis hanging around in suspicious places. Better round them up. Do that by going to each left parenthesis and see where its matching right side is.

One thing I recommend is eliminate a bit of Arrow-Code Anti-Pattern ( https://blog.codinghorror.com/flattening-arrow-code/ ) by getting rid of the easy possibilities first:
If differ is less than 0, you can return right away with the fixedSalary.
All the code after that can safely assume that differ is greater or equal to 0 (meaning the sales person met their quota).

DeanMSands3 69 Junior Poster

The dead post - !
... It - it lives again! What have you done??!

That which was dead should have stayed dead! The grave will not be lightly robbed her rightful prize.

You fools! You've doomed us all!

DeanMSands3 69 Junior Poster

Aaaaannnddd there's your problem. Everyone give a warm round of applause and +1's to Mike for an excellent response.
However, once again, we ...
I don't even know how to put this gently to the OP:
Don't frakking use Turbo C.
OK, let's qualify that statement with: Don't use Turbo C outside a DOSBox instance, and even then, only use it to explain the history of programming to someone else or for your own personal sick amusement (guilty!).
But for actual programming there are better options and this question has been answered several, several times.

TL;DR:

Stop using Turbo C.
Go get Visual Studio Express or Code::Blocks or the Qt SDK or Orwell Dev C++.

DeanMSands3 69 Junior Poster

Made a few more edits. I realized I was failing to initialize the bits variable in BitCount. Then I realized this code would also hang on negative numbers. Not sure how you wanted that handled. I went with casting as unsigned which will give you the "Two's Complement" value.

EDIT:
@Perry31:
Ah. I see.

DeanMSands3 69 Junior Poster

O.O
I... I'm really not sure what to say here.

#include <stdio.h>
#include <stdlib.h>
//Declare prototypes
unsigned int BitCount(unsigned int);
char *BinaryFormat(void*);

int main()
{
    char *binaryString;
    int Input = 0;

    scanf_s("%d", &Input);
    binaryString=BinaryFormat((void*)&Input); //Use reference to Input instead of Input's value.

    printf("\nThe Binary format for the given is : %s", binaryString); //Its no longer crashing here
    free(binaryString); //Clean up after yourself when using dynamic allocation.
}

//
//Coverting the given input to Binary data
//
char* BinaryFormat(void *Input) //Why void*?
{
    char *binFormat = NULL;
    unsigned int num = *((unsigned int*)Input); //Cast Input as Input pointer, then grab referenced value.

    //Counting number of bits needed
    unsigned int bitCount = BitCount((int)num); //This will return number of digits needed. This is separate fn

    //Allocating Input based on number of digit(bit value) needed
    binFormat = (char*) calloc(1,bitCount+1);

    if (num)
    {
        binFormat[bitCount]=0; //As a precaution.
        while(bitCount)
        {
            //Filling binFormat either with 1's or 0's based on number
            binFormat[bitCount-1] = num&1 ? '1' : '0'; //Use '1' and '0'

            num = num >> 1;
            bitCount--;
        }
    }else{
        binFormat[0]=0; //Send back an empty string
    }
    //returning final value as string
    return binFormat;
}

unsigned int BitCount(unsigned int number){
    unsigned int bits=0; //EDIT: Oops. I forgot to make sure this was initialized to zero.
    while(number){
        number >>= 1;
        bits++;
    }
    return bits;
}
DeanMSands3 69 Junior Poster
DeanMSands3 69 Junior Poster

@happygeek: I remember seeing an article for these some 15 years ago when I was in high school. The article reviewed these exactly as you described - high wow-factor, but not very usable. (You might have even written the article.)

Was wondering if they were ever going to come back.

DeanMSands3 69 Junior Poster

Well, if you removed the data types from where you call the function in line 39...
o.O

DeanMSands3 69 Junior Poster

I'm assuming that Text1-3 are text boxes.
I'd grab their "text" properties, then cast them to integers.
In programmer-ese, that's

Picture1.BackColor RGB(cint(Text1.Text),cint(Text2.Text),cint(Text3.Text))

OK, now correct me if I'm wrong (It's been forever since VB6 for me), but doesn't this need an equal sign between Picture1.BackColor and RGB(...) ?

Picture1.BackColor=RGB(cint(Text1.Text),cint(Text2.Text),cint(Text3.Text))

Also, I did some digging and it looks like you also need your Picture1.AutoRedraw set to true.

Hope that helps.

alina.nazchowdhury commented: thanks a lot, i knew something's missing, i have this book but sometimes the code is not done properly +0
DeanMSands3 69 Junior Poster

Remember that Java like C uses "zero based" arrays. That means that if an array has 7 elements, it's indices go from 0 to 6. With i<=A.length, you're setting i to 0 through 7. But A[7] doesn't exist. Hence the out of bounds exception.

            //Change i<=A.length to i<A.length
            for (int i=0; i < A.length; i++){
                  TextIO.putln(A[i]);
            }
DeanMSands3 69 Junior Poster

OK... strange... it didn't post this morning. Here's the repost:

#include <vector> //Include the header for the vector data type
#include <iostream> //Accept input and give output.
#include<fstream>

using namespace std; //Using the std namespace for coding simplicity

int main(){
    vector<double> test1,test2;
    double num;
    int i=0,j;
    ifstream infile;
    infile.open("input.txt");
    while(true){
        //First column
        infile>>num;
        if(!infile.good()) break; //If it's not good break.
        if(infile.eof()) break; //If it's the end of the file break.
        test1.push_back(num); //Back of the line for you, mister!

        //Second column
        infile>>num;
        if(!infile.good()) break; //If it's not good break.
        if(infile.eof()) break; //If it's the end of the file break.
        test2.push_back(num); //Back of the line for you, mister!

        i++; //And one more row please.
    }

    //Print them back out switched just for variety.
    for(j=0;j<i;j++){
        cout<<test2[j]<<"\t"<<test1[j]<<endl; //Notice I'm printing test2 first, then test1.
    }

    test1.clear(); //Clean up and free up!
    test2.clear();
    infile.close();
    return 0;
}

Here's the data set I used to test it:

0.5 -1.0
1.5 -2.0
2.5 -3.0
3.5 -4.0
4.5 -5.0

And here's what it prints out:

-1 0.5
-2 1.5
-3 2.5
-4 3.5
-5 4.5

DeanMSands3 69 Junior Poster

Ignore the bit about system("pause"); . I was being sarcastic. That's just something veteran coders use to humiliate junior coders. Using it IS a bad habit, but one that most of us (myself included) start out with.

As to your question, instead of double test1[size], test2[size]; use vector<double> test1, test2;
Next, read the numbers from infile into a temporary variable (make sure to declare it first).
Then, use the push_back member function to add the number into test1 or test2.
(A member function is a class function whose actions are -generally- specific to the object calling it).
You check the End of File flag on infile to see if you've run out of data.
I'll post an example shortly. First I need to rotate my laundry.

DeanMSands3 69 Junior Poster

How about a nice example?

//moo.h

#include <string>
extern std::string moo; //Declare the variable externally without actually creating it.


//moo.cpp
#include "moo.h"
std::string moo="Moo."; //Now we initialize the variable and give it an actual definition.


//moomain.cpp
#include "moo.h"
#include <iostream>
int main(){
    //Print out a happy message using the externally declared variable.
    std::cout<<"The cow says '"<<moo<<"' How I hate that cow."<<std::endl;
    return 0;
}


//Command line I used:
(Compiling)
$ g++ moo.cpp moomain.cpp -o moomain
(Running)
$ ./moomain
(Expected output)
The cow says 'Moo.' How I hate that cow.
DeanMSands3 69 Junior Poster

First off, you've committed an unpardonable sin on DaniWeb. You used system("pause"); Using getch(); is not better. This is a crime punishable by excessive belittling, arrogant condescension, and ostricism by the veteran community members.
I don't make the rules, and I am not making this up.
(The fix is to compile in the IDE, then run from the command-line, or find something in the preferences to

Second, you're attacking the problem the wrong way. Where (n) is not a constant, you want dynamic arrays in one form or fashion. The not fun way is to create the array with a single data slot, then allocate a new one, copy, and delete the old one every single time you add a new number.
This is less than ideal.

The "right way" (read: oh so much easier), is to use the pre-bundled Standard Template Library data types, most notably vector.
Here's an example:

#include <vector> //Include the header for the vector data type
#include <iostream> //Accept input and give output.

using namespace std; //Using the std namespace for coding simplicity

int main(){
    vector<double> array;
    double num;
    int i=0,j;
    cin.clear(); //clear any error flags
    cout<<"Please enter as many numbers as you like followed by a non-number to quit."<<endl; //So polite!

    //Accept an undefined number of double-precision floats.
    while(true){
        cin>>num;

        //Makes sure that the input type was the right data type.
        //(i.e. putting a string of letters into a number variable would be bad.)
        if(!cin.good()) break; 

        array.push_back(num); //Back of …
DeanMSands3 69 Junior Poster

"const int mazeArray" may have something to do with that.

DeanMSands3 69 Junior Poster

cout and pretty much everything else in the Standard Template Library (i.e. the header files without the .h at the end) are members of the std namespace.

On line #2 add in: using namespace std;

DeanMSands3 69 Junior Poster

Those work, but they tend to be slow.
Have you looked into Multi Precision Number libraries?
There's GMP and MPFR to name a few.
FYI: uint64_t will get you into the very shallow end of 20-digit numbers (i.e. 0-18446744073709551615)

DeanMSands3 69 Junior Poster

EDIT: @AD: I seriously thought so too, but I googled it first.
SECOND EDIT: @rithish: DO NOT DO THIS UNLESS YOU KNOW WHAT YOU'RE DOING!
Apparently, you can. I'd try it first on your compiler just to be sure.
Make sure it's pointed at a valid memory location that has been allocated.
http://stackoverflow.com/questions/3473675/negative-array-indexes-in-c

#include <stdio.h>

int main(){
    int array[16];
    int *ptr=array+8;
    int i;
    for(i=0;i<16;i++)
        array[i]=i;
    for(i=-8;i<8;i++)
        printf("ptr[%d]:%d\t", i, ptr[i]);
    return 0;
}

(Tested in MinGW 4.7 on Windows XP x86, then GCC 4.6 in Ubuntu x64)

DeanMSands3 69 Junior Poster

Are you using this on your PC or an XBox 360?
Look into XInput:
http://msdn.microsoft.com/en-us/library/hh405053(v=vs.85)

Here's a useful tutorial to get started (not quite what you were looking for, but it's the right direction.)
http://www.codeproject.com/Articles/26949/Xbox-360-Controller-Input-in-C-with-XInput

DeanMSands3 69 Junior Poster

Yeah, what WaltP said. Edit: And Labdabeta.
Ouch. Ouch. Ouch. This code really hurt me. I kept thinking that a finite state machine version would be a better approach. Ask if you're interested.
Back to your code, I debugged far enough to get it sort of working. It took a lot longer than I'd have liked it to.

int s=i; should be int s=i-1;

                    if (isValidCharacter(emails[s]) == false)
                    {
                        s++;
                        if(isValidCharacter(emails[s]) == true) break;
                    }

should be

                    if (isValidCharacter(emails[s]) == false)
                    {
                        s++;
                        if(isValidCharacter(emails[s]) == true) break;
                        else if(s==i) break;
                    }

int e = i; should be int e = i+1;

if(e = emails.length()) break; should be if(e == emails.length()) break;

if(e == '.') should be if(emails[e] == '.')

There's a few other changes I made.

Here's a full listing of my code with lines added for debugging. It's not %100, but it's better than nothing.

#include <fstream>
#include <iostream>
#include <string>
using namespace std;

class toLower{public: char operator() (char c) const {return tolower(c) ;}};

bool isValidCharacter(char c)
{
    bool validCheck = false;
    if ((c>='A' && c<= 'Z') || (c>='a' && c<='z') || (c>='0' && c<='9') || (c=='.') || (c=='-') || (c=='+'))
    validCheck = true;
    return validCheck;
}

int main()
{
    ifstream fin;

    string inputFile;
    string outputFile;
    string defaultInput = "fileContainingEmails.txt";
    string defaultOutput = "copyPasteMyEmails.txt";

    cout << "Enter input filename[default: fileContainingEmails.txt]: ";
    getline(cin, inputFile);

    if (inputFile.length() == 0)
    {
        inputFile = defaultInput;
        outputFile = defaultOutput;
        cout << "Enter output filename[default: copyPasteMyEmails.txt]: …
DeanMSands3 69 Junior Poster

@Critical Error: From the frontpage, "Our Geeks' Lounge forum is the place to chat about anything. Have fun and relax in this forum."
Technically, I could start topic about rutabagas and asparagus. I'd get down-voted for it, but I could still do it.
@Hani1991: Carry on, sir. Carry on.

DeanMSands3 69 Junior Poster

Ref: http://msdn.microsoft.com/en-us/library/windows/desktop/ms681944(v=vs.85).aspx
Are you running in a seperate process?
Are you familiar with multiple processes?
Are you familiar with Interprocess communication? (It's really really fun!)

A Windows process can only be tied to one console at a time. So... create a new process. From that process, call FreeConsole. The console WON'T be destroyed. Then call AllocConsole.

I haven't researched too deeply, but if you want some backup I'll be happy to help.

triumphost commented: Helpful! +5
DeanMSands3 69 Junior Poster

The specification is hosted by libPNG here: http://www.libpng.org/pub/png/spec/1.2/PNG-Contents.html

Read the specification and figure out how to write a decoder.
If you've never worked with compression algorithms before like LZW and LZMA, it's probably a good idea to start now.

Actually, actually...
forget all that.
Start with a GIF decoder. Learn the ins and outs of image compression. THEN try tackling something as nuts as PNG.
http://www.w3.org/Graphics/GIF/spec-gif89a.txt

Edit: I've never actually written one, so if you're up for the challenge, I'll be happy to work with you on it.

DeanMSands3 69 Junior Poster

Here's a hands on example.

(A good reference to look at first:) http://stackoverflow.com/questions/1395591/what-is-exactly-the-base-pointer-and-stack-pointer-to-what-do-they-point

I modified the C code a little:

int foo=1;
int main(int argumentCount, char *arguments[])
{
    const char* bar = "Hello, Daniweb!";
    char *firstArg;
    int num;
    num=1;
    num=argumentCount;
    num=0;
    firstArg=arguments[1];
    firstArg=(char *)0;

    return num;   
}

I compiled using MinGW: gcc -S blah.c
This is a 32-bit system. YMMV.
Assembly:

    .file   "blah.c"
    .globl  _foo
    .data
    .align 4
_foo:
    .long   1
    .def    ___main;    .scl    2;  .type   32; .endef
    .section .rdata,"dr"
LC0:
    .ascii "Hello, Daniweb!\0"
    .text
    .globl  _main
    .def    _main;  .scl    2;  .type   32; .endef
_main:
LFB0:
    .cfi_startproc
    pushl   %ebp
    .cfi_def_cfa_offset 8
    .cfi_offset 5, -8
    movl    %esp, %ebp
    .cfi_def_cfa_register 5
    andl    $-16, %esp
    subl    $16, %esp
    call    ___main
    movl    $LC0, 12(%esp)
    movl    $1, 8(%esp)
    movl    8(%ebp), %eax
    movl    %eax, 8(%esp)
    movl    $0, 8(%esp)
    movl    12(%ebp), %eax
    movl    4(%eax), %eax
    movl    %eax, 4(%esp)
    movl    $0, 4(%esp)
    movl    8(%esp), %eax
    leave
    .cfi_restore 5
    .cfi_def_cfa 4, 4
    ret
    .cfi_endproc
LFE0:

As you can see, the "Hello" text is in the .data segment and not the .text segment where the code is.

Now let's look at what this actually does:
(The .cfi commands are pre-assembler directives and can be ignored for our purposes.)
EBP is the frame pointer.
It gets saved with pushl %ebp
ESP is the stack pointer.
At first they are set equal to each other by movl %esp, %ebp
It looks like ESP is being byte-aligned to 16 …

DeanMSands3 69 Junior Poster

This post is effectively solved and needs to be marked as such, but for the reference of anyone coming along later, here's what happened:
The sin_addr contains a 32-bit unsigned long int. Not a string. 127.0.0.1 as a number would look like 0x7F000001 or 2130706433 in decimal. The numbers 49, 50, 55, 46 are the ASCII codes for '1', '2', '7', and '.' respectively. A memcpy would do a byte for byte copy of the string "127.0.0.1". I feel sorry for whoever's at 49.50.55.46. They must get this all the time.

Instead you need to use inet_pton (inet_aton is now deprecated).
For a more in-depth look at sockets, have a look at the venerated Beej's Guide to Network Programming.

When Chuck Norris wants to roundhouse kick a browser into existence, he asks Beej for advice first.

DeanMSands3 69 Junior Poster

Hm... for the moment, I'm going to say I was wrong about everything and leave it at that.
I'm still looking over the assembly (and I'm very rusty with GNU assembler), but being as my job expects me to produce results before the end of the day, I probably need to put this away for now.

Happy coding all.

DeanMSands3 69 Junior Poster

@Sokurenko: I'm not the kind of guy who down-votes posts willy-nilly (unless you're being condescending and a complete ass), but your post is... not what the OP is asking for. Pass by value, not reference. Yours is reference. Granted, your code is instructive to new coders and you're not rude, so no down-voting.

@Deceptikon: Back in the days of Turbo C, I remember folks saying never put an array in the arguments, and instead use its pointer AND the same thing about struct's. Back then, passing by value would obliterate the then-miniscule memory stack like no tomorrow. I'm tempted to say that if you pass an array of specific size to a function expecting a specific size, it will pass by value, but I don't know. I'll compile some code as small as I can get it and read the assembly to see. Of course, that'll only prove one compiler for one platform. Meh.

As an aside, in some countries the days of Turbo C seem to be today, tomorrow, and the day after that.

DeanMSands3 69 Junior Poster

In Line 4, you're allocating a char buffer and assigning it to TempString.
And you need to add 1 to account for the trailing zero. strlen will only get the non-zero characters.
In Line 5, you're assigning String to TempString, overwriting the pointer to the buffer you'd just created. Um...why?
That buffer is gone and you can't get it back.
The rest of it I'm too lazy to check, though it looks like it would work though not the way I'd do it.
Have a look at strstr. It does a body good.

int i=0;
int j=0;
char      *TempString;
TempString = (char*)malloc((strlen(String)+1)*sizeof(char));
//TempString = String;
    while(String[i])
    {
        if((String[i] == '1') && (String[i+1] == '2')) // Deleting string "123" 
        {   
            while(String[i] != '3')
                i++;
            i++;
            flagcount++;
        }
        TempString[j] = String[i];//its crashing here while debugging.
        i++; j++;
    }
    TempString[j]=0;    
DeanMSands3 69 Junior Poster

I'm going to go into pedantic mode for a bit. Apologies if either of you are offended in the process.

And here I thought I was being the insufferable troll. ;)

DeanMSands3 69 Junior Poster

Also, here's an instructional video from Stanford on using Pointers.
Stanford Explains Pointers
I'm putting this as a second post as my first post deserves an up-vote while this post, despite its clearly educational value, will brand me as an insufferable troll.
And I probably deserve that.
Enjoy!

DeanMSands3 69 Junior Poster

OK. This is a common problem for beginners. You have a pointer (*a). This pointer points to nothing.
You do a scanf into the pointer. The program has an aneurysm. The stock market collapses! Puppies and kittens around the world suddenly vanish!
Heh. So yeah. *a needs something to point to.

Try one of the following:
1: Using an array.

#include <stdio.h>
#include <conio.h>

void main()
{
    char a[101];

    printf("Enter the string: ");
    scanf("%s",&a); //You can keep the ampersand, but you don't need it here.

    printf("\nEntered string is :%s", a);
    getch();
}

2: Allocating a buffer.

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
void main()
{
    char *a;
    a=(char*)malloc(101*sizeof(char));
    printf("Enter the string: ");
    scanf("%s",a);  // You definitely don't want the ampersand here.
                    //That'd be a pointer to a pointer

    printf("\nEntered string is :%s", a);
    getch();
    free(a);
}

Now, why did I use 101 as my size? C needs a zero terminator at the end of its strings, so you have to allocate +1 more than the size you want.

Perry31 commented: Thanks for prompt reply.. +0
DeanMSands3 69 Junior Poster

OK. Let's see your code.

DeanMSands3 69 Junior Poster

Put in checkpoints in your code like printf("Client: Now entering client function.");

Tell us what happens.

DeanMSands3 69 Junior Poster

Use the dynamically linked glew32.
Reference:
http://forums.codeblocks.org/index.php?topic=13055.0;wap2

I also included a picture showing that what settings I'm using in Eclipse. I don't have NetBeans on this system. ProjectSettings

This is a picture of a Smurf swimming in a lake.
Smurf

DeanMSands3 69 Junior Poster

OK, the #pragma bit doesn't factor in with MinGW. You've got to tell the linker what you're using.
You'll need to go to Project Properties and Linker settings. I can't remember the exact location so lmgtfy:
http://lmgtfy.com/?q=netbeans+C%2B%2B+linker+libraries
You need to link in glew32, opengl32, and gdi32 - in that order.
Make sure to do that for both Debug and Release.

Make sure that the glew32.dll is somewhere in your system path. (It's in the lib folder, but that probably won't work. I copied mine to the bin folder.) Otherwise, your program will croak prematurely.

Also, I compiled and ran the program. It's blue. That's it. That's the great smurfing mystery. It's Microsmurf Cornflower blue. That's all there is.

DeanMSands3 69 Junior Poster

Uh... hm...
It's... um... astonishingly easy. If you've ever used MSYS. Which you probably haven't.

OK, so assume I have a full MinGW and MSYS install.
I download the source file (at https://sourceforge.net/projects/glew/files/glew/1.7.0/glew-1.7.0.tgz/download ) to my C:\Workspace\Source folder.

I open MSYS which takes me to a command-line. I change to the C:\Workspace\Source folder.
cd /c/Workspace/Source
I unzip the tar-ball.
tar -xzf glew-1.7.0.tgz
I change to the glew-1.7.0 folder.
cd glew-1.7.0

I openthe Makefile in Wordpad (formerly called Write).
write Makefile
I scroll down a few pages until I see:
GLEW_DEST ?= /usr
I change it to:
GLEW_DEST ?= /mingw
I save and close Wordpad.

I run the Makefile with the make program. This compiles the binaries.
make

Then, when it finishes,
make install
This copies the binaries and header files where the compiler can use them.

It's ready to rock.

DeanMSands3 69 Junior Poster

The Visual Studio libraries probably aren't going to work for MinGW (what Dev C++ compiles with).
MinGW = Minimal GNU for Windows.

And Dev C++ is kind of dead anyway.

Get a full MinGW installation (GCC & G++) with at least a minimal MSYS that has Make.
Then get Eclipse or NetBeans as your IDE. (NetBeans, at least for me, has always felt "friendlier.")

Meanwhile, I'm going to see if I can get Glew built for MinGW.

DeanMSands3 69 Junior Poster

Have a look at WinPCap and the related project WireShark.
Good luck and happy coding.

DeanMSands3 69 Junior Poster

This question has already been answered the last time you posted this. The BGI error is telling you that your program compiled by Borland Turbo C++ can't find the right file for its graphics library.
And yes, we only need to see the article title to know it's Turbo C++. Though, the #include's would have been a second clue.
What you need to do is set your path to include the directory you have your BGI files in.
Or copy the right BGI file into the same directory as your executable. (But you'd have to do that every time.)
Actually, what you need to do is drop Turbo C++ and move on to bigger and better things. Things you can get for free. Legally.
If you're interested in porting this program to something usable, let us know in the forums or send me a PM.

rahulraj9 commented: help him +0
DeanMSands3 69 Junior Poster

Learn regular expressions.
Boost::Regex

DeanMSands3 69 Junior Poster

In regards to your redundant class X;, remove them from the beginning of each header not counting A.h. You're including the header files so you don't need an additional class statement.

In regards to the run-time error: yes, exactly. A pointer is not the object it points to. It's like having a mailbox without a house.

#include "D.h"
#include <string>
class D;
int main(){
    D* d=new D(); //Add Me!
    d->add();
    d->sh();
//  d->show();
    return (0);
}

EDIT: Credit goes to gusano79 whose post I've already up-voted.

DeanMSands3 69 Junior Poster

Alpha channel perhaps?

DeanMSands3 69 Junior Poster

Engine001 is suitable for what you want.
First, visualize what you want. You want to create a Role-Playing game.

Then start small. Make a game with a single room and a single character.
Write some backstory on that character. Why is he or she in the room? What does he or she hope to accomplish? Also, the room. What is the purpose of the room?
Then create another room. What is the purpose of that room?

Experiment. Can you open doors? Open chests? Turn on switches? And so on.

Create another character for your first character to meet and join with? What's this character's motivations for joining? What's the cause? Is it money, power, the building of a better world, or plain boredom?

What is the opposition to your quest? A secret band of assassins? Evil robots from outer space? A vast world government? Vegetarian chickens come to wreak havoc on the ignorant meat-eating masses?

See what you can do.
We expect great things.

DeanMSands3 69 Junior Poster

The Compiler is expecting you to use a Class object with those functions unless you declare them as static.
In your header, put static in front of the declarations (i.e. right before the word void), but not in the implementation.

DeanMSands3 69 Junior Poster
If the input for the gender doesn't match 'F' and doesn't match 'M' complain and exit.
if(gender!='F'&&gender!='M'){
    cout<<"Invalid Gender."<<endl;
    return 0;
}

If the input for the activity doesn't match 'I' and doesn't match 'A' complain and exit.
if(level!='I'&&gender!='A'){
    cout<<"Invalid Activity Level."<<endl;
    return 0;
}
DeanMSands3 69 Junior Poster

You can't use arrays? Can you use linked lists or trees?
EDIT: How did we all reply at the same time?

DeanMSands3 69 Junior Poster

Fantastic. I'm glad to have helped.

DeanMSands3 69 Junior Poster

A char tends to be 8 bits.
An int on a 32-bit machine is 32-bits.
If an int contains a 2, it actually contains {2,0,0,0} (in a 32-bit system)
Try this code:

#include<stdio.h>

int main()
{
	unsigned int i, j;
	int arr[3]={2,3,4};
	char *p;
//	p = (char*)arr;         // line A
	for(i=0;i<3;i++){
		printf("Integer:%d\n",arr[i]);

		for(j=0;j<sizeof(int);j++){	//I'm using sizeof(int) to get the exact size of int. I can't assume it's 4.
			p=(char*)&arr[i];	//point p at arr
			p+=j;			//move p to current byte
			printf("Byte[%d]:%d\n",j,*p);
		}
		printf("*********\n");
	}
	return 0;
}

Why do I not know the size of int?
An int is usually the size of the number of bits in the system it's compiled for.
This can be 16, 32, or 64.
Note that just because I run a program on a 64-bit system, doesn't mean I'm getting 64-bits. If it's a 32-bit program, it's a 32-bit number.

student_learner commented: gives the accurate answer. :) +1
DeanMSands3 69 Junior Poster
long fileSize;
fseek(input, 0L, SEEK_END); //Go to end of file
fileSize = ftell(input); //Current position is the file length
rewind(input); //Rewind to beginning

Then just do a for loop.

As for speed, your fgetc is killing you. Single character reads is too slow.
Once you know your file size, malloc a buffer, and fread into it.
Then fwrite out.