1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<html> 3<!-- Copyright (C) 1988-2021 Free Software Foundation, Inc. 4 5Permission is granted to copy, distribute and/or modify this document 6under the terms of the GNU Free Documentation License, Version 1.3 or 7any later version published by the Free Software Foundation; with the 8Invariant Sections being "Free Software" and "Free Software Needs 9Free Documentation", with the Front-Cover Texts being "A GNU Manual," 10and with the Back-Cover Texts as in (a) below. 11 12(a) The FSF's Back-Cover Text is: "You are free to copy and modify 13this GNU Manual. Buying copies from GNU Press supports the FSF in 14developing GNU and promoting software freedom." --> 15<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ --> 16<head> 17<title>Debugging with GDB: C Constants</title> 18 19<meta name="description" content="Debugging with GDB: C Constants"> 20<meta name="keywords" content="Debugging with GDB: C Constants"> 21<meta name="resource-type" content="document"> 22<meta name="distribution" content="global"> 23<meta name="Generator" content="makeinfo"> 24<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 25<link href="index.html#Top" rel="start" title="Top"> 26<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index"> 27<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> 28<link href="C.html#C" rel="up" title="C"> 29<link href="C-Plus-Plus-Expressions.html#C-Plus-Plus-Expressions" rel="next" title="C Plus Plus Expressions"> 30<link href="C-Operators.html#C-Operators" rel="previous" title="C Operators"> 31<style type="text/css"> 32<!-- 33a.summary-letter {text-decoration: none} 34blockquote.smallquotation {font-size: smaller} 35div.display {margin-left: 3.2em} 36div.example {margin-left: 3.2em} 37div.indentedblock {margin-left: 3.2em} 38div.lisp {margin-left: 3.2em} 39div.smalldisplay {margin-left: 3.2em} 40div.smallexample {margin-left: 3.2em} 41div.smallindentedblock {margin-left: 3.2em; font-size: smaller} 42div.smalllisp {margin-left: 3.2em} 43kbd {font-style:oblique} 44pre.display {font-family: inherit} 45pre.format {font-family: inherit} 46pre.menu-comment {font-family: serif} 47pre.menu-preformatted {font-family: serif} 48pre.smalldisplay {font-family: inherit; font-size: smaller} 49pre.smallexample {font-size: smaller} 50pre.smallformat {font-family: inherit; font-size: smaller} 51pre.smalllisp {font-size: smaller} 52span.nocodebreak {white-space:nowrap} 53span.nolinebreak {white-space:nowrap} 54span.roman {font-family:serif; font-weight:normal} 55span.sansserif {font-family:sans-serif; font-weight:normal} 56ul.no-bullet {list-style: none} 57--> 58</style> 59 60 61</head> 62 63<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> 64<a name="C-Constants"></a> 65<div class="header"> 66<p> 67Next: <a href="C-Plus-Plus-Expressions.html#C-Plus-Plus-Expressions" accesskey="n" rel="next">C Plus Plus Expressions</a>, Previous: <a href="C-Operators.html#C-Operators" accesskey="p" rel="previous">C Operators</a>, Up: <a href="C.html#C" accesskey="u" rel="up">C</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p> 68</div> 69<hr> 70<a name="C-and-C_002b_002b-Constants"></a> 71<h4 class="subsubsection">15.4.1.2 C and C<tt>++</tt> Constants</h4> 72 73<a name="index-C-and-C_002b_002b-constants"></a> 74 75<p><small>GDB</small> allows you to express the constants of C and C<tt>++</tt> in the 76following ways: 77</p> 78<ul> 79<li> Integer constants are a sequence of digits. Octal constants are 80specified by a leading ‘<samp>0</samp>’ (i.e. zero), and hexadecimal constants 81by a leading ‘<samp>0x</samp>’ or ‘<samp>0X</samp>’. Constants may also end with a letter 82‘<samp>l</samp>’, specifying that the constant should be treated as a 83<code>long</code> value. 84 85</li><li> Floating point constants are a sequence of digits, followed by a decimal 86point, followed by a sequence of digits, and optionally followed by an 87exponent. An exponent is of the form: 88‘<samp>e<span class="roman">[[</span>+<span class="roman">]|</span><span class="nolinebreak">-</span><span class="roman">]</span><var>nnn</var><!-- /@w --></samp>’, where <var>nnn</var> is another 89sequence of digits. The ‘<samp>+</samp>’ is optional for positive exponents. 90A floating-point constant may also end with a letter ‘<samp>f</samp>’ or 91‘<samp>F</samp>’, specifying that the constant should be treated as being of 92the <code>float</code> (as opposed to the default <code>double</code>) type; or with 93a letter ‘<samp>l</samp>’ or ‘<samp>L</samp>’, which specifies a <code>long double</code> 94constant. 95 96</li><li> Enumerated constants consist of enumerated identifiers, or their 97integral equivalents. 98 99</li><li> Character constants are a single character surrounded by single quotes 100(<code>'</code>), or a number—the ordinal value of the corresponding character 101(usually its <small>ASCII</small> value). Within quotes, the single character may 102be represented by a letter or by <em>escape sequences</em>, which are of 103the form ‘<samp>\<var>nnn</var></samp>’, where <var>nnn</var> is the octal representation 104of the character’s ordinal value; or of the form ‘<samp>\<var>x</var></samp>’, where 105‘<samp><var>x</var></samp>’ is a predefined special character—for example, 106‘<samp>\n</samp>’ for newline. 107 108<p>Wide character constants can be written by prefixing a character 109constant with ‘<samp>L</samp>’, as in C. For example, ‘<samp>L'x'</samp>’ is the wide 110form of ‘<samp>x</samp>’. The target wide character set is used when 111computing the value of this constant (see <a href="Character-Sets.html#Character-Sets">Character Sets</a>). 112</p> 113</li><li> String constants are a sequence of character constants surrounded by 114double quotes (<code>"</code>). Any valid character constant (as described 115above) may appear. Double quotes within the string must be preceded by 116a backslash, so for instance ‘<samp>"a\"b'c"</samp>’ is a string of five 117characters. 118 119<p>Wide string constants can be written by prefixing a string constant 120with ‘<samp>L</samp>’, as in C. The target wide character set is used when 121computing the value of this constant (see <a href="Character-Sets.html#Character-Sets">Character Sets</a>). 122</p> 123</li><li> Pointer constants are an integral value. You can also write pointers 124to constants using the C operator ‘<samp>&</samp>’. 125 126</li><li> Array constants are comma-separated lists surrounded by braces ‘<samp>{</samp>’ 127and ‘<samp>}</samp>’; for example, ‘<samp>{1,2,3}</samp>’ is a three-element array of 128integers, ‘<samp>{{1,2}, {3,4}, {5,6}}</samp>’ is a three-by-two array, 129and ‘<samp>{&"hi", &"there", &"fred"}</samp>’ is a three-element array of pointers. 130</li></ul> 131 132<hr> 133<div class="header"> 134<p> 135Next: <a href="C-Plus-Plus-Expressions.html#C-Plus-Plus-Expressions" accesskey="n" rel="next">C Plus Plus Expressions</a>, Previous: <a href="C-Operators.html#C-Operators" accesskey="p" rel="previous">C Operators</a>, Up: <a href="C.html#C" accesskey="u" rel="up">C</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p> 136</div> 137 138 139 140</body> 141</html> 142