Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,159 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,919 people online right now. Registration is fast and FREE... Join Now!




Buffers----Need Help!

 
Reply to this topicStart new topic

Buffers----Need Help!

aviator
6 Dec, 2007 - 04:45 PM
Post #1

New D.I.C Head
*

Joined: 31 Oct, 2007
Posts: 30


My Contributions
Any ideas of the errors in this little program to get it finaly to work?

CODE



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

#define BUFFSIZE 100

int main(void)

{

unsigned char ucBuffer[BUFFSIZE];
unsigned char ucBufferPointer;
void initBuffer(void);
unsigned char ucData;
void pushBuffer(unsigned char);
unsigned char popBuffer(void);
int iLoop;

initBuffer();

printf("generating some characters\n");
for(iLoop=0;iLoop<26;iLoop++)
{
ucData = (unsigned char)(0x41 + iLoop);
printf("%c",ucData);
pushBuffer(ucData);
}
printf("Getting data from the buffer\n");

for(iLoop=0;iLoop<26;iLoop++)
{
ucData = popBuffer();
printf("%c",ucData);
}
return 0;
}




Error when i compile it!

ld:
Unresolved:
initBuffer
pushBuffer
popBuffer


User is offlineProfile CardPM
+Quote Post

NickDMax
RE: Buffers----Need Help!
6 Dec, 2007 - 10:43 PM
Post #2

2B||!2B
Group Icon

Joined: 18 Feb, 2007
Posts: 2,858



Thanked: 49 times
Dream Kudos: 550
My Contributions
...are you kidding me?

I know that I am just in a bad mood tonight and aggrivated by all the users asking us to do thier homework but really.

you need to read some basic tutorials on C or get a book. You continue to post code that is just wrong in basic construction.

The errors tell it all. Unresolved means that the compiler/linker does not know what the symbol is --- usually means that you did not define this symbol.

So the first one: initBuffer()... the first occurance of it is a declaration INSIDE MAIN!!! WTF! have you EVER written a C program? WHY is this here? for that matter why are ANY function prototypes in the main() function!

So here is the basic layout of C program:

CODE

//First thing in the file would be special compiler directives to control the compiler, these are rare.

//Next thing is includes: They are here so that they can be used from here down
#include <stdio.h>
#include <stdlib.h>

//Preprocessor macros
#define BUFFSIZE 10

//typedefs/structs/enums/unions/etc any data structures that may be used

//Function declarations
void initBuffer(void);
void pushBuffer(unsigned char);
unsigned char popBuffer(void);

//global variables

//Now we can finally get around to main()
int main() {
    //declare variables
    unsigned char ucBuffer[BUFFSIZE];
    unsigned char ucBufferPointer;
    unsigned char ucData;
    int iLoop;

    //code
    initBuffer();

    printf("generating some characters\n");
    for(iLoop=0;iLoop<26;iLoop++) {
        ucData = (unsigned char)(0x41 + iLoop);
        printf("%c",ucData);
        pushBuffer(ucData);
    }
    printf("Getting data from the buffer\n");

    for(iLoop=0;iLoop<26;iLoop++) {
        ucData = popBuffer();
        printf("%c",ucData);
    }
    return 0;
}

//Here we define the functions that we decalred
void initBuffer(void) {

}

void pushBuffer(unsigned char) {

}

unsigned char popBuffer(void) {

}


I will no longer respond to posts from you if the program does not follow this basic format... and as I am the only one who has been responding to your posts, your only chance is to LEARN how to avoid the mistakes you are making over and over.
User is offlineProfile CardPM
+Quote Post

skaoth
RE: Buffers----Need Help!
7 Dec, 2007 - 10:39 AM
Post #3

D.I.C Regular
Group Icon

Joined: 7 Nov, 2007
Posts: 342



Thanked: 10 times
Dream Kudos: 100
My Contributions
Your not the only one tired of this.
I posted a version that compiles

http://www.dreamincode.net/forums/showtopic38582.htm

Why the same thing keeps getting posed I don't know.
User is online!Profile CardPM
+Quote Post

no2pencil
RE: Buffers----Need Help!
7 Dec, 2007 - 10:43 AM
Post #4

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 6,446



Thanked: 66 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
QUOTE(skaoth @ 7 Dec, 2007 - 11:39 AM) *

Your not the only one tired of this.
I posted a version that compiles

http://www.dreamincode.net/forums/showtopic38582.htm

Why the same thing keeps getting posed I don't know.


Bah, who needs int main(void) ?

It's over-rated anyhow.

User is online!Profile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 11:46PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month