06-21-2011
Help with understanding ( int, char, long, short, signed, unsigned etc.... )
My question is simple: When should I use a long, int, char, unsigned/signed variables??
When I declare a variable "unsigned;" what did I do it???
Why would I delcare an integer "long" or "short" ( unsigned or signed)??
Any examples of when things like "unsigned", "long", "short" etc... should, and shouldn't be used???
Can anybody explain the usage of long, int, char, unsigned/signed with some simple example?
I got "google" about this problem...
But can't really get any answer got well explanation among long, int, char, unsigned/signed variables.
Help will be appreciated.
10 More Discussions You Might Find Interesting
1. Programming
How can I store and/or print() a number that is larger than 4 294 967 295 in C? is int64_t or u_int64_t what I need ? if, so how can I printf it to stdout? (2 Replies)
Discussion started by: nimnod
2 Replies
2. Programming
hi,
Please help me with the following code to get the difference in values.
struct a{
int b1;
int c1;
char d1;
}
main()
{
unsigned int b=10;
unsigned int c;
c = b - (unsigned int )sizeof(a);
printf("%d",c);
}
Here c returns some junk value. How can i get the... (2 Replies)
Discussion started by: naan
2 Replies
3. UNIX for Dummies Questions & Answers
hello everybody!
I want to create a file with permissions for read, write, and execute to everybody using C, so I write this code:
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main(){
int fileDescriptor;
fileDescriptor =... (2 Replies)
Discussion started by: csnmgeek
2 Replies
4. Red Hat
Hello everey one,
here i am attempting to compile a c++ project .it's throughing the following errors.
my machine details are as follows:
Linux chmclozr0119 2.6.18-53.el5 #1 SMP Wed Oct 10 16:34:19 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux
errors:
=====
Generating... (0 Replies)
Discussion started by: mannam srinivas
0 Replies
5. Shell Programming and Scripting
Hi ,
I am using getopt for both short and long options as below
SHORTOPTS="a:c"
LONGOPTS="alpha:,charlie"
OPTS=$(getopt -o $SHORTOPTS --longoptions $LONGOPTS -n "$progname" -- "$@")
eval set -- "$OPTS"
while ; do
case $1 in
-a|--alpha)
echo "-a or --alpha... (1 Reply)
Discussion started by: padmisri
1 Replies
6. Shell Programming and Scripting
Hi All,
I have written the below to add the numbers in a column. Postive numbers are unsigned and negative numbers are signed in the file. After the below cmd I am getting -0.00 , instead of 0.00. Can someone guide me on what I am missing in the cmd.
grep '^L' $FileName| awk -F"|" ' {... (7 Replies)
Discussion started by: gsjdrr
7 Replies
7. Programming
Hi,
I wrote a simple code in C++ converting from UpperToLower case characters. However, my compiler gives me a warning:
"warning: conversion to 'char' from 'int' may alter its value".
Any tips?
I would like to stress, I don't want to load my string into char array.
int ToLower(string... (4 Replies)
Discussion started by: kajolo
4 Replies
8. Programming
/******************************************************************************/
/* Printing an unsigned character in bits */
#include <stdio.h>
void display_bits ( unsigned char );
int main()
{
unsigned char x; /*... (15 Replies)
Discussion started by: robin_simple
15 Replies
9. Programming
when a date type is considered signed and unsigned is that simple referring to - for signed and positive numbers for unsigned? Further if that is the case would mutiplying and dividing ect where 2 signed numbers, like (-2)*(-2) = 4 result in a unsigned. (3 Replies)
Discussion started by: Fingerz
3 Replies
10. OS X (Apple)
Hi guys...
Macbook Pro, 13", circa August 2012, OSX 10.7.5, default bash terminal.
I require the capability to convert +32767 to -32768 into signed hex words...
The example piece code below works perfectly except...
#/bin/bash
# sign.sh
# Unsign to sign...
while true
do
# I have used... (2 Replies)
Discussion started by: wisecracker
2 Replies
OUTB(2) Linux Programmer's Manual OUTB(2)
NAME
outb, outw, outl, outsb, outsw, outsl, inb, inw, inl, insb, insw, insl, outb_p, outw_p, outl_p, inb_p, inw_p, inl_p - port I/O
SYNOPSIS
#include <sys/io.h>
unsigned char inb(unsigned short int port);
unsigned char inb_p(unsigned short int port);
unsigned short int inw(unsigned short int port);
unsigned short int inw_p(unsigned short int port);
unsigned int inl(unsigned short int port);
unsigned int inl_p(unsigned short int port);
void outb(unsigned char value, unsigned short int port);
void outb_p(unsigned char value, unsigned short int port);
void outw(unsigned short int value, unsigned short int port);
void outw_p(unsigned short int value, unsigned short int port);
void outl(unsigned int value, unsigned short int port);
void outl_p(unsigned int value, unsigned short int port);
void insb(unsigned short int port, void *addr,
unsigned long int count);
void insw(unsigned short int port, void *addr,
unsigned long int count);
void insl(unsigned short int port, void *addr,
unsigned long int count);
void outsb(unsigned short int port, const void *addr,
unsigned long int count);
void outsw(unsigned short int port, const void *addr,
unsigned long int count);
void outsl(unsigned short int port, const void *addr,
unsigned long int count);
DESCRIPTION
This family of functions is used to do low-level port input and output. The out* functions do port output, the in* functions do port
input; the b-suffix functions are byte-width and the w-suffix functions word-width; the _p-suffix functions pause until the I/O completes.
They are primarily designed for internal kernel use, but can be used from user space.
You must compile with -O or -O2 or similar. The functions are defined as inline macros, and will not be substituted in without optimiza-
tion enabled, causing unresolved references at link time.
You use ioperm(2) or alternatively iopl(2) to tell the kernel to allow the user space application to access the I/O ports in question.
Failure to do this will cause the application to receive a segmentation fault.
CONFORMING TO
outb() and friends are hardware-specific. The value argument is passed first and the port argument is passed second, which is the opposite
order from most DOS implementations.
SEE ALSO
ioperm(2), iopl(2)
COLOPHON
This page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
Linux 2012-12-31 OUTB(2)