like i have a string ch[100] how can i convert each character of it to integer that is ascii value which can be later converted in to binary so that ascii value of each character in a string has a corresponding binary value

Recommended Answers

All 3 Replies

You don't need to convert because char is already an integer(8bit integer). You can directly assign it to integer.

for(i = 0; i < 100; i++)
  num[i] = ch[i];

Like he said :)

which can be later converted in to binary so that ascii value of each character in a string has a corresponding binary value

From what I understand, you want to convert char to int. That has been answered. Then you want to convert the int to binary. Where do you want to store that binary value? In another array? Please specify.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.