Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

help in string manipulation (mikroc)

Status
Not open for further replies.

asrock

Junior Member level 3
Joined
Sep 10, 2010
Messages
26
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,538
hello every one


i would ask you in issue i faced it when i make a simple prog....
if i have a string series such as
char st[10]="683664791"

here i want to get every character and convert it to integer to make on it some math operations...

the problem is : how i can get ceratin character in (st) !

here's my try:
char st[10]="683664791"
int num;

num=atoi(st[0]) // for example i want to get "6" and convert to int number
---------------
but its not working


help me plz :(
 


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
unsigned int sum = 0, i = 0, j = 0;
unsigned number;
 
j = slrlen(st)-1; //if strlen = 8 then j = 7
 
while(st[i]){
    
    number = number + (st[i]-0x30)*10pow(j--);
    i++;
}
 
//number contains 68366471
 
/*
number = 0 + 6*10^7 = 60000000
number = 60000000 + 8*10^6 = 68000000
number = 68000000 + 3*10^5 = 68300000
number = 68300000 + 6*10^4 = 68360000
number = 68000000 + 6*10^3 = 68366000
number = 68000000 + 4*10^2 = 68366400
number = 68000000 + 7*10^1 = 68366470
number = 68000000 + 1*10^0 = 68366471
*/

 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top