|
-
May 27th, 2001, 07:54 AM
#1
Thread Starter
Lively Member
what's wrong with this code?
Hi All,
I just have a general question which i hope someone can solve for me.
I'm trying to create a .a lib file, that passes paramters etc, but i keep getting a stupid compiler erro, can someone tell me what's wrong with this code?
Code:
#include <iostream.h>
//The black Co-Ordinate
char coutblack[8](int srow)
{
char cb[8];
switch(srow)
{
case 0 : cb[8] = {' ' , ' ' , ' ' , ' ' , '|' , ' ' , ' ' , ' ' , ' ' }
break;
case 1 : cb[8] = {' ' , ' ' , ' ' , '@' , '@' , '@' , ' ' , ' ' , ' ' }
break;
case 2 : cb[8] = {' ' , ' ' , '@' , '@' , '@' , '@' , '@' , ' ' , ' ' }
break;
case 3 : cb[8] = {'-' , '@' , '@' , '@' , '@' , '@' , '@' , '@' , '-' }
break;
case 4 : cb[8] = {' ' , ' ' , '@' , '@' , '@' , '@' , '@' , ' ' , ' ' }
break;
case 5 : cb[8] = {' ' , ' ' , ' ' , '@' , '@' , '@' , ' ' , ' ' , ' ' }
break;
case 6 : cb[8] = {' ' , ' ' , ' ' , ' ' , '|' , ' ' , ' ' , ' ' , ' ' }
break;
default:
break;
}
return cb[8];
}
The goal of the code is to return the value of cb[8] based on whatever srow is inputed as i.e. 1 however, i keep getting a few stupid little errors any help would be greatly appreciated!
Thanks 
Regards,
Smithy.
-
May 27th, 2001, 08:19 AM
#2
Monday Morning Lunatic
You can't arbitrarily assign to arrays since they're stored as a single number representing a memory location (a pointer).
A better idea would be something like:
Code:
#include <iostream.h>
void coutblack(int srow, char *pcDest) {
static char ppcData[8][8] = {
{' ' , ' ' , ' ' , ' ' , '|' , ' ' , ' ' , ' ' , ' ' },
{' ' , ' ' , ' ' , '@' , '@' , '@' , ' ' , ' ' , ' ' },
{' ' , ' ' , '@' , '@' , '@' , '@' , '@' , ' ' , ' ' },
{'-' , '@' , '@' , '@' , '@' , '@' , '@' , '@' , '-' },
{' ' , ' ' , '@' , '@' , '@' , '@' , '@' , ' ' , ' ' },
{' ' , ' ' , ' ' , '@' , '@' , '@' , ' ' , ' ' , ' ' },
{' ' , ' ' , ' ' , ' ' , '|' , ' ' , ' ' , ' ' , ' ' }
};
memcpy(pcDest, ppcData[srow], 8);
}
void somecode() {
char pcData[8];
coutblack(3, pcData);
}
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
May 27th, 2001, 08:22 AM
#3
Thread Starter
Lively Member
thanks!
Ok,
Thanks for the advice!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|