•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 456,594 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,479 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums
Views: 479 | Replies: 2
![]() |
•
•
Join Date: Apr 2007
Posts: 9
Reputation:
Rep Power: 0
Solved Threads: 0
Hi,
This is a segmant of my code that iam working on, for some reason its not giving out the expected output
which is 11010111. It gives me "elements: ☺ ☺ ☺ ☺ ☺ ☺" and its really bugging me cuz it looks right. Any help would be appriciated. Thanks
This is a segmant of my code that iam working on, for some reason its not giving out the expected output
which is 11010111. It gives me "elements: ☺ ☺ ☺ ☺ ☺ ☺" and its really bugging me cuz it looks right. Any help would be appriciated. Thanksunsigned char ipans[8],ipb[4]={1,0,1,1},epans[8];
int ep[8] = {4,1,2,3,2,3,4,1};
int main()
{
int x;
printf("elements: ");
for(x=0;x<8;x++)
{
epans[x] = ipb[ep[x]-1];
printf("%c " ,epans[x]);
} Yes, Salem is right, %c gives you a character with a corresponding code, not a number, 1 1 0 1 0 1 1 1 is exactly what your program outputs when you use %d. Also, when you initialize the arrays, you don't always have to provide the size, like in your program ipb [] = {1, 0, 1, 1} would work as well. One more thing, when you use the initialized arrays, it's often better to not use the array size anywhere, to avoid an unnecessary magic number. Like, in your array ep, the elements most likely cannot be 0, so, you can end this array with zero, and iterate until zero.
Last edited by TkTkorrovi : Sep 7th, 2007 at 1:04 pm.
Knowledge is regarded by the fool as ignorance, and the things that are profitable are to him hurtful. He liveth in death. -- Thoth the Atlantean
![]() |
•
•
•
•
•
•
•
•
DaniWeb C Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Array (C++)
- trouble with long output string, plz help (PHP)
- Displaying values of an array (C++)
- did I used Array??? (C++)
- Unexpected output when program exucuted (C++)
- Using a variable as an array's index? (C)
- C++ complete binary tree using an array. Unexpected end file (C++)
- Array without twice the same number? (C)
- How do I create a program using an Array ? (C++)
Other Threads in the C Forum
- Previous Thread: debugging shared object
- Next Thread: Coding a SYN scanner guide



Linear Mode