•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 403,028 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 2,807 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: 259 | Replies: 3 | Solved
![]() |
hi all,
i am new to programming,
my problem is that after certain data manipulation i will a array which will have only zeros & ones. (example x[5]={0,0,1,0,1}
now i would like to store the contents of the array in another variable like A(say)=00101.
but the codes which i written saves it as A=101.
code which wrote is
//
//
please help me
thank u
i am new to programming,
my problem is that after certain data manipulation i will a array which will have only zeros & ones. (example x[5]={0,0,1,0,1}
now i would like to store the contents of the array in another variable like A(say)=00101.
but the codes which i written saves it as A=101.
code which wrote is
//
c Syntax (Toggle Plain Text)
p=0; A=0; for(i=0;i<=4;i++) { for(s=i;s<=5;s++) { p=10*p; } A=A+(m[i]*p); p=1; }
please help me
thank u
Last edited by Ancient Dragon : Jun 11th, 2008 at 7:48 am. Reason: add code tags
hi all,
i am new to programming & to this site,
plz let me clarify the problem further.
my problem is that after certain data manipulation (in a function) i will a array which will have only zeros & ones & twos. (example x[10]={0,0,1,0,1,2,2,2,2,2},x[10]={1,0,1,2,2,2,2,2,2,2},x[10]={0,0,0,1,1,1,0,0,2,2} etc...)
now i would like to store the contents of the array in another variable like A(say)=00101, A=101,A=00011100.
(ignoring all 2s but keeping all preceding 0s. 2s represent junk values )
but the codes which i written saves it as A=101,A=101,A=11100.
code which i wrote is
//
//
please help me
thank u
i am new to programming & to this site,
plz let me clarify the problem further.
my problem is that after certain data manipulation (in a function) i will a array which will have only zeros & ones & twos. (example x[10]={0,0,1,0,1,2,2,2,2,2},x[10]={1,0,1,2,2,2,2,2,2,2},x[10]={0,0,0,1,1,1,0,0,2,2} etc...)
now i would like to store the contents of the array in another variable like A(say)=00101, A=101,A=00011100.
(ignoring all 2s but keeping all preceding 0s. 2s represent junk values )
but the codes which i written saves it as A=101,A=101,A=11100.
code which i wrote is
//
c Syntax (Toggle Plain Text)
int i,j,t,s; int A,p; for(i=0;i<10;i++) { t=0; A=0; while(x[i]!=2) { t++; } p=1; for(j=0;j<=t;j++) { for(s=t;s>=(t-j);s--) { p=10*p; } A=A+(m[j]*p); p=1; } }
please help me
thank u
Last edited by Ancient Dragon : Jun 11th, 2008 at 7:48 am. Reason: add code tags -- again
•
•
Join Date: Jun 2008
Posts: 79
Reputation:
Rep Power: 1
Solved Threads: 7
May I suggest you use the digits 1, 2 & 3, instead of 0, 1, & 2?
Because you can't "make" a number which begins with 0's: 01, 001, 02, 002, etc., are not a number. Anything beginning with a real number, would be fine though: 101, 20, 103, etc.
Other idea's would include using bit values within the bytes, but that sounds unnecessarily difficult for a beginner, and keeping the values in an integer array, where the zero's would be fine.
Always put your code between code tags on any forum.
Because you can't "make" a number which begins with 0's: 01, 001, 02, 002, etc., are not a number. Anything beginning with a real number, would be fine though: 101, 20, 103, etc.
Other idea's would include using bit values within the bytes, but that sounds unnecessarily difficult for a beginner, and keeping the values in an integer array, where the zero's would be fine.
Always put your code between code tags on any forum.
Last edited by Adak : Jun 11th, 2008 at 3:28 am.
•
•
•
•
May I suggest you use the digits 1, 2 & 3, instead of 0, 1, & 2?
Because you can't "make" a number which begins with 0's: 01, 001, 02, 002, etc., are not a number. Anything beginning with a real number, would be fine though: 101, 20, 103, etc.
Other idea's would include using bit values within the bytes, but that sounds unnecessarily difficult for a beginner, and keeping the values in an integer array, where the zero's would be fine.
Always put your code between code tags on any forum.
thanks for helping. solved the problem
![]() |
•
•
•
•
•
•
•
•
DaniWeb C Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
access advice broadband business classification code combo crime cult of the dead cow daniweb data data protection data transfer database drive dropdownlist encryption europe forensic forensics gadget google government hacking hard hardware help hitachi hp industrial espionage information internet linux mobile module net news payment services privacy protection reuse search security spot storage terabyte tutorials and more tv web wikipedia
- Previous Thread: Compiler understands the lang. Who understands the compiler?
- Next Thread: Adding sound/midi to C


Linear Mode