By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,996 Members | 884 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,996 IT Pros & Developers. It's quick & easy.

C Code for cryptographic algorithm

P: 1
i have a problem... i have to seperate numbers from digits. For example i have a cryptographic code done which gives me the output as
2_three_06_one_01_four_32_two_3
I need to seperate the numbers and print them like it should be 2 6 13 23
Oct 30 '15 #1
Share this Question
Share on Google+
4 Replies


weaknessforcats
Expert Mod 5K+
P: 9,197
Can't you just read your input a byte at a time and check whether the byte value is between 49 and 57 on the ascii table.? or pass your byte to isdigit()?
Oct 30 '15 #2

P: 16
char rawdata[]="2_three_01_six"
int i = 0
while i<rawdata.length()
{
if string.isdigit(rawdata[i]) && rawdata[i-1]!='_'
print rawdata[i]
i=i+1
}
Will this work?? @weaknessforcats
Oct 31 '15 #3

Expert 100+
P: 2,396
@jaseel97 you need to print some separator (space, new line, etc) between numbers.
Oct 31 '15 #4

weaknessforcats
Expert Mod 5K+
P: 9,197
@jaseel97:
It worked for me. Of course, I had to fix the code errors but the logic flow is correct.
Oct 31 '15 #5

Post your reply

Sign in to post your reply or Sign up for a free account.