Half a croissant, on a plate, with a sign in front of it saying '50c'
h a l f b a k e r y
actual product may differ from illustration

idea: add, search, annotate, link, view, overview, recent, by name, random

meta: news, help, about, links, report a problem

account: browse anonymously, or get an account and write.

user:
pass:
register,


     

single quote in C could mean char array, not just single char

 
(0)
  [vote for,
against]

At the moment

"a" --> 'a', '\n' : Valid C

'a' --> 'a' : Valid C

But 'ab` is invalid

'ab' ---> INVALID C

---------

This seems a bit inconvenient if you want to write printable character without a null terminator.

What would be nice is if you are allowed to type this

'subsys_3' ---> {'s','u','b','s','y','s','_','3'}

mofosyne, Jun 30 2017

[link]






       To write a string without a null terminator, just specify the array length; if there's no room for the terminator, it'll be omitted. Dress it up in a macro if you want it to be more maintainable:   

       char variable[8] = "subsys_3";
Wrongfellow, Jun 30 2017
  

       Well, at least it's not in {other} ' general;
normzone, Jun 30 2017
  
      
[annotate]
  


 

back: main index

business  computer  culture  fashion  food  halfbakery  home  other  product  public  science  sport  vehicle