SHARE
TWEET

Untitled

a guest Sep 6th, 2013 28 Never
  1. void g(char c, signed char sc, unsigned char uc)
  2. {
  3.     c = 255; //implementation-defined if plain chars are signed and have 8 bits
  4.     c = sc; //OK
  5.     c = uc; //implementation-defined if plain chars are signed and if uc's value is too large
  6.     sc = uc; //implementation-defined if uc's value is too large
  7.     uc = sc; //OK: conversion to unsigned
  8.     sc = c; //implementation-defined if plain chars are unsigned and if c's value is too large
  9.     uc = c; //OK: conversion to unsigned
  10. }
  11.        
  12. signed char sc = -160;
  13. unsigned char uc = sc; //uc == 116 (because 256-160==116)
  14. cout << uc; //print 't'
RAW Paste Data
Top