How do i convert value back to const char

#include <stdio.h>
#include <iostream>

using namespace std;

int main()
{
    int i, value;
    const char text[] = "456";
    for (i = 0, value = 0; text [i] != '\0'; ++i)
    {
        int digit = text [i] - '0';
        value = 10 * value + digit;
    }
    value++;
    cout<<value<<"\n";
    system("pause");
    return 0;
}

Recommended Answers

All 2 Replies

int a=123;
ostringstream os;
os<<a;
string s = os.str();
string s("123");
int a;
istringstream is(s);
is>>a;

const char* from a string object is obtained from a call to member function c_str()

Thanks stoned coder
I found this

sprintf( text, "%d", value);

worked when i dropped the const from const char text[]

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.