View unanswered posts | View active topics It is currently Tue Oct 21, 2014 7:57 pm






Reply to topic  [ 3 posts ] 
RobotC 3.51 Request #1 - Pointer Array initialization 
Author Message
Rookie

Joined: Fri Apr 15, 2011 10:29 am
Posts: 37
Post RobotC 3.51 Request #1 - Pointer Array initialization
Not necessarily a bug, but a request none-the-less, and it's really easy to work-around.

Code:
// These three initializations should be identical
char *buff = { 'a', 'b', 'c' };
char buffer[] = { 'a', 'b', 'c' };
char *sbuff = "abc";

task main()
{
}


The last two work fine, but the first fails.


Sat Sep 29, 2012 1:34 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: RobotC 3.51 Request #1 - Pointer Array initialization
nateww wrote:
Not necessarily a bug, but a request none-the-less, and it's really easy to work-around.

Code:
// These three initializations should be identical
char *buff = { 'a', 'b', 'c' };
char buffer[] = { 'a', 'b', 'c' };
char *sbuff = "abc";

task main()
{
}

The last two work fine, but the first fails.

Your code doesn't look right. buff is declared as a char pointer but the initialization is trying to init an array of char. I just pasted this code to Visual Studio and it gave me the following error. So it is indeed correct for RobotC to reject it.
Code:
1>c:\temp\visual studio 2012\projects\consoleapplication1\consoleapplication1\test.cpp(6): error C2440: 'initializing' : cannot convert from 'char' to 'char *'
1>          Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast


Sat Sep 29, 2012 2:06 pm
Profile
Rookie

Joined: Fri Apr 15, 2011 10:29 am
Posts: 37
Post Re: RobotC 3.51 Request #1 - Pointer Array initialization
Boy, my C is getting rusty. It's been awhile....


Sat Sep 29, 2012 9:37 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.