string to integer

February 22, 2019
string to integer
#include <iostream>
using namespace std;
int main()
{
    char str[7]={"525134"};
    int  num[20]={0};
    int n = 0,i=0;
    for( i = 0; i<7;i++)
    {

        n = str[i]-48;
        num[i]= n;
    }
    for(int x=0;x<6;x++)
    {
        cout<<num[x]-1<<endl;
    }
    return 0;
}

No comments:

'; (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })();
Powered by Blogger.