register Variables in C
By: Grenfel
A register declaration advises the compiler that the variable in question will be heavily used. The idea is that register variables are to be placed in machine registers, which may result in smaller and faster programs. But compilers are free to ignore the advice.The register declaration looks like
register int x; register char c;and so on. The register declaration can only be applied to automatic variables and to the formal parameters of a function. In this later case, it looks like
f(register unsigned m, register long n) { register int i; ... }In practice, there are restrictions on register variables, reflecting the realities of underlying hardware. Only a few variables in each function may be kept in registers, and only certain types are allowed. Excess register declarations are harmless, however, since the word register is ignored for excess or disallowed declarations. And it is not possible to take the address of a register variable, regardless of whether the variable is actually placed in a register. The specific restrictions on number and types of register variables vary from machine to machine.
Archived Comments
1. abookzrar
View Tutorial By: abookzrar at 2017-05-16 03:37:52
2. WayneNub
View Tutorial By: WayneNub at 2017-04-27 22:10:43
3. If i give register int a[100], what will happen? Say if 10 registers are available in the hardware,
View Tutorial By: ramkumar at 2017-01-28 09:41:23
4. Lyrica Ancef
View Tutorial By: Lyrica AncefSP at 2016-11-20 05:05:49
5. RichardJal
View Tutorial By: RichardJal at 2015-08-27 04:26:05
6. EruroErardDot
View Tutorial By: EruroErardDot at 2015-04-02 12:06:13
7. SitsCistmix
View Tutorial By: SitsCistmix at 2013-05-19 21:23:45
8. Can you provide some more specific application of keyword 'register' ,please?
View Tutorial By: Rushikesh at 2012-01-15 18:23:36
Comment on this tutorial
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Related Tutorials
Sum of the elements of an array in C
Printing a simple histogram in C
Find square and square root for a given number in C
Simple arithmetic calculations in C
Passing double value to a function in C
Passing pointer to a function in C
Infix to Prefix And Postfix in C
while, do while and for loops in C