Non null-terminated string compiler option for gcc

Update

turns out this is just another case of "c++ is not c blues"


What I want

const char hex[16] = "0123456789ABCDEF";

the only thing that works

char hex[16] = "0123456789ABCDE"; hex[15] = "F";

are there any compiler options or something I can do to make strings not null terminated in the gcc compiler. so that I can make a(n) constant array

Answers


No need for a compiler option, it's already non-NUL terminated. The standard says a NUL should only be added if it can fit, otherwise it would be an overflow. It may just be that the next byte in memory past your array is \0

§ 6.7.8p14 An array of character type may be initialized by a character string literal, optionally enclosed in braces. Successive characters of the character string literal (including the terminating null character if there is room or if the array is of unknown size) initialize the elements of the array.


Need Your Help

Concatenating strings in C++

c++ linux g++

I am rather inexperienced C++ programmer, so this question is probably rather basic. I am trying to get the file name for my copula:

How to detect Pivot View using MVVM in WP7?

c# silverlight windows-phone-7 mvvm mvvm-light

basically I have a pivot control in my WP7 app that contains 3 views. On each view I'm calling 1 of my 3 different web services that I run. What I'm trying to do is call the service only when they

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.