You are missing the null terminator at the end, but that shoulden't explain why its outputting the address of t . The correct way to do it would be like this:
char trig [10] = "cos(50)"; //declare and assign the char array "trig"
char t [4]; //declare char array t to store the "cos" part of the trig array
t[0] = trig[0];
t[1] = trig[1];
t[2] = trig[2];
t[3] = '\0';
Try that and see if it works
William Hemsworth
Posting Virtuoso
1,591 posts since Mar 2008
Reputation Points: 1,429
Solved Threads: 129
Well, I compiled the code and it worked perfectly for me, so mabey its something to do with your compiler settings.
William Hemsworth
Posting Virtuoso
1,591 posts since Mar 2008
Reputation Points: 1,429
Solved Threads: 129
Could you post the exact code your using ?
Nick Evan
Not a Llama
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403
That's a long winded way of doing it:
Other options include using std::strings and relevant functions such as substr()
And other c-style string functions...
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439