Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

The GNU C Programming Tutorial - Assigning variables to one another

Node:Assigning variables to one another, Next:, Previous:Characters, Up:Bits and pieces



Assigning variables to one another

Not only can you assign numbers to variables, you can assign other variables to variables:

var1 = 23;
var2 = var1;

The variable or value on either side of the = symbol must usually be of the same type. However, integers and characters will interconvert because characters are stored by their ASCII codes (which are integers!) Thus the following will work:

int i;
char ch = 'A';

i = ch;

printf ("The ASCII code of %c is %d",ch,i);

The result of this would be:

The ASCII code of A is 65

 
 
  Published under free license. Design by Interspire