LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-02-2007, 03:56 PM   #1
ashlesha
Member
 
Registered: May 2005
Location: PA
Distribution: Ubuntu
Posts: 204

Rep: Reputation: 30
Lightbulb getint like a getchar?


hey,

is there an getint function similar to getc, while reading files in C -- to read 16bit integer values instead of character values?

Thanks,
Ashlesha.
 
Old 04-02-2007, 04:10 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
read() ?
Code:
#include    <stdio.h>
#include    <stdlib.h>

int main( int argc, char * argv[] ){

int integer;
int bytesRead;

    bytesRead = read( fileno( stdin ), &integer, sizeof( int ) );
    printf( "The integer is decimal %d, hex %X (%d bytes read)\n", integer, integer, bytesRead );
    exit( integer );
}
--- rod.

Last edited by theNbomr; 04-02-2007 at 04:12 PM.
 
Old 04-03-2007, 10:54 AM   #3
ashlesha
Member
 
Registered: May 2005
Location: PA
Distribution: Ubuntu
Posts: 204

Original Poster
Rep: Reputation: 30
Thanks Rod --
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
getchar() satellite Programming 10 12-24-2017 01:47 PM
about getchar() captainstorm Programming 6 10-11-2003 04:14 AM
getchar() NSKL Programming 18 01-11-2003 10:19 AM
getchar() not working? lackluster Programming 3 06-24-2002 08:09 AM
getchar() Winter Programming 6 05-11-2002 01:49 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration