[ create a new paste ] login | about

Link: http://codepad.org/pIRv1Fx8    [ raw code | output | fork ]

Layvian - C, pasted on May 18:
/*
learning.c
05-18-2012
Layvian
-----------
The purpose of this program is to store
character values into memory using pointers.
*/

#include <stdio.h>
#include <stdbool.h>

void lifeState(void);
void learnStorage(int status, int *pStatus);
void responseIn(char *pMemSlot1[4], char *pMemSlot2[4]);
void responseOut(char memSlot1[4], char memSlot2[4]);

int main(){
lifeState();
return 0;
}

/*
Life State Function

While this function is in the Loop the program
will continiue to store char values in memory.

Once ended the life state will end displaying
the output of the two stored values and their
address.
*/
void lifeState(void){

int status = 1;
int *pStatus;
pStatus = &status;

do{
learnStorage(status, pStatus);

}while(status == 1);

printf("End\n");
}

//Learn Storage Function
void learnStorage(int status, int *pStatus){

/*
MEMORY SLOT 1

Created with two types:
1. Character
2. Boolean

Each has a pointer that references the originals
address.  Once the variable slot contains a char,
it will be entered into the IF logic to switch the
FALSE status of the "memSlot1Full", to TRUE.
*/
char memSlot1[4];
char *pMemSlot1[4];
pMemSlot1 = &memSlot1;
_Bool memSlot1Full = false;
_Bool *pMemSlot1Full;
pMemSlot1Full = &memSlot1Full;


/*
MEMORY SLOT 2

Created with two types:
1. Character
2. Boolean

Each has a pointer that references the originals
address.  Once the variable slot contains a char,
it will be entered into the IF logic to switch the
FALSE status of the "memSlot2Full", to TRUE.
*/
char memSlot2[4];
char *pMemSlot2[4];
pMemSlot2 = &memSlot2;
_Bool memSlot2Full = false;
_Bool *pMemSlot2Full;
pMemSlot2Full = &memSlot2Full;

responseIn(pMemSlot1, pMemSlot2);

printf("%s\n", memSlot1);

*pStatus = 0;

}


//Response Out Function
//Response In Function
void responseIn(char *pMemSlot1[4], char *pMemSlot2[4]){

char responseOne[4] = "Eart";
char responseTwo[4] = "Mars";

*pMemSlot1 = responseOne;
*pMemSlot2 = responseTwo;

}


//Response Out Function
void reponseOut(char memSlot1, char memSlot2){

}


Output:
1
2
3
In function 'learnStorage':
Line 64: error: incompatible types in assignment
Line 84: error: incompatible types in assignment


Create a new paste based on this one


Comments: