hi, i am a newbie and i just started to learn C++.
My question is , if i put a number like 45678 in char x[6] then how do i separate each number and put it into int num[6].
k_en
0
Light Poster
Recommended Answers
Jump to Postsomthing like this:
#include <iostream> int main () { char c[6] = "45678"; int num[5]; for (int i = 0; i < 5; i++) { char temp = c[i]; num[i] = atoi(&temp); std::cout << num[i] << std::endl; } system("pause"); }
All 4 Replies
zyruz
0
Junior Poster in Training
k_en
0
Light Poster
Rashakil Fol
978
Super Senior Demiposter
Team Colleague
Drowzee
3
Posting Whiz in Training
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.