Results 1 to 4 of 4
I would like to optimize a C program ..Do you think it would be useful to use
datatype as register (for frequently used variables ) rather than using it auto ...
- 01-12-2009 #1
C programming - register data type
I would like to optimize a C program ..Do you think it would be useful to use
datatype as register (for frequently used variables ) rather than using it auto?
Have you ever implemented register in your programs?
Ex:
rather thanregister int i;
auto int i ; // or just int ;- Lakshmipathi.G
-------------------
FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
-------------------
- 01-12-2009 #2
Personally I would use inline assembler before I would use register(it gives the programmer more control)...if your interested in optimizing programs try reading up on the -O switch in gcc...Hope this helps Gerard
- 01-13-2009 #3
Thanks Gerard ..that's very useful suggestion.
I'll try it out...
- Lakshmipathi.G
-------------------
FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
-------------------
- 06-01-2010 #4Just Joined!
- Join Date
- Jun 2010
- Posts
- 1
Data Type in Programming
I declared a variable as int data type which was a placeholder for a result status (meaning, based on the result status that variable varies from 0/1/2/3. It can contain only these four values).
“int” data type is 4 byte integer in C#. But I can declare this variable as “sbyte” which represents a 1 byte integer. Since that variable contains only 1 or 2 or 3 or 4, declaring the variable as “int” is wastage of memory space.
Before declaring any variable we need to just think of the memory space needed for that variable, our requirement, any other good alternative for this variable.


