Sponsored Content
Top Forums Programming Using write() with integers in C Post 302165622 by jim mcnamara on Friday 8th of February 2008 10:05:48 AM
Old 02-08-2008
Code:
int i=13;
write(my_fd, &i, sizeof(i));

This stores the internal integer the way it is stored in memory inside the file.
To make it human readable, assuming 32 bit integers:
Code:
char tmp[12]={0x0};
int i=13;
sprintf(tmp,"%11d", i);
write(my_fd, tmp, sizeof(tmp));

This writes a nul terminated string to the disk.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

integers in the if statement

hi, im trying to compare two variables in csh to put in an if statement, eg: set a = $firstnum set b = $secondnum if ($a -ge $b) echo $a But I get an error ("if: Expression syntax"). How can I make csh see my variables as integers? thanks in advance! (5 Replies)
Discussion started by: Deanne
5 Replies

2. Shell Programming and Scripting

Unix Scripting Compare Integers

I have a file with the following: 87565 82155 102656 151 162 I want to write korn shell script that will read each line in a loop and remove any number that has less than 5 digits, e.g., 151 and 152. thank you, Keoki:confused: (4 Replies)
Discussion started by: keoki_mel
4 Replies

3. Shell Programming and Scripting

Add non-integers using ksh

I would like to add 4.7 and 1.2. However I am unable to do this with expr. Any simple ideas (even using something other than expr)? Example: me> expr 4 + 1 5 me> expr 4.7 + 1.2 expr: 0402-046 A specified operator requires numeric parameters. (18 Replies)
Discussion started by: 2dumb
18 Replies

4. Shell Programming and Scripting

integers, floats and text

I am using gawk in a dos shell in windows xp and want to read a datafile and reformat it. The datafile consists of columns of integers, floating point numbers and text strings. Each column is a fixed width and each column contains the same data type, eg all integers, all text. I am looking for a... (0 Replies)
Discussion started by: lookingfor help
0 Replies

5. IP Networking

read/write,write/write lock with smbclient fails

Hi, We have smb client running on two of the linux boxes and smb server on another linux system. During a backup operation which uses smb, read of a file was allowed while write to the same file was going on.Also simultaneous writes to the same file were allowed.Following are the settings in the... (1 Reply)
Discussion started by: swatidas11
1 Replies

6. Shell Programming and Scripting

Cancel down 2 integers

Wonderful evening to all of you! My problem has to possible starting points. Well, not really, but getting to either one is no problem at all. So i got either a string in the format of "1920x1080" or simply the integers X = 1920 and Y = 1080. When I am done, I would like to have an output... (5 Replies)
Discussion started by: jakunar
5 Replies

7. Shell Programming and Scripting

Grep float/integers but skip some integers

Hi, I am working in bash in Mac OSX, I have following 'input.txt' file: <INFO> HypoTestTool: >>> Done running HypoTestInverter on the workspace combined <INFO> HypoTestTool: The computed upper limit is: 11 +/- 1.02651 <INFO> HypoTestTool: expected limit (median) 11 <INFO> HypoTestTool: ... (13 Replies)
Discussion started by: Asif Siddique
13 Replies

8. Shell Programming and Scripting

Bash Integers/String

Hy friends, I am newbie to bash scripting, can anyone explain how b=${a/23/BB} # Substitute "BB" for "23". this line converts "b" into string and and "d" into Integer. Thanks in advance (4 Replies)
Discussion started by: Qazi
4 Replies

9. UNIX for Dummies Questions & Answers

Strings to integers?

Hi, I'm totally new at this, so help will be appreciated. I have a directory with a bunch of files in it. The files are named xinteger_yinteger_zinteger.vtk (eg, x3_y0_z-1.vtk). I want to read the filenames and then assign the integers to variables that I then can use in expressions. So, for... (6 Replies)
Discussion started by: jhsinger
6 Replies

10. Shell Programming and Scripting

Comparing Integers (I think)

Hi, I can't figure out what I'm missing. I'm running a query to see if there are any streams recording on my DVR before starting a scripted update. I'm guessing that it is viewing $VIDEO as a string instead of an int. I've tried everything I saw on google but it still comes back as $VIDEO is... (8 Replies)
Discussion started by: Rhysers
8 Replies
SoGLModelMatrixElement(3)					       Coin						 SoGLModelMatrixElement(3)

NAME
SoGLModelMatrixElement - The SoGLModelMatrixElement class is yet to be documented. FIXME: write doc. SYNOPSIS
#include <Inventor/elements/SoGLModelMatrixElement.h> Inherits SoModelMatrixElement. Public Member Functions virtual void init (SoState *state) FIXME: write doc. virtual void push (SoState *state) FIXME: write doc. virtual void pop (SoState *state, const SoElement *prevTopElement) FIXME: write doc. Static Public Member Functions static SoType getClassTypeId (void) static int getClassStackIndex (void) static void * createInstance (void) static void initClass (void) Protected Member Functions virtual ~SoGLModelMatrixElement () virtual void makeEltIdentity () FIXME: write doc. virtual void setElt (const SbMatrix &matrix) FIXME: write doc. virtual void multElt (const SbMatrix &matrix) FIXME: write doc. virtual void translateEltBy (const SbVec3f &translation) FIXME: write doc. virtual void rotateEltBy (const SbRotation &translation) FIXME: write doc. virtual void scaleEltBy (const SbVec3f &scaleFactor) FIXME: write doc. virtual SbMatrix pushMatrixElt () FIXME: write doc. virtual void popMatrixElt (const SbMatrix &matrix) FIXME: write doc. Additional Inherited Members Detailed Description The SoGLModelMatrixElement class is yet to be documented. FIXME: write doc. Constructor &; Destructor Documentation SoGLModelMatrixElement::~SoGLModelMatrixElement (void) [protected], [virtual] The destructor. Member Function Documentation SoType SoGLModelMatrixElement::getClassTypeId (void) [static] This static method returns the class type. Reimplemented from SoModelMatrixElement. int SoGLModelMatrixElement::getClassStackIndex (void) [static] This static method returns the state stack index for the class. Reimplemented from SoModelMatrixElement. void * SoGLModelMatrixElement::createInstance (void) [static] This API member is considered internal to the library, as it is not likely to be of interest to the application programmer. Reimplemented from SoModelMatrixElement. void SoGLModelMatrixElement::initClass (void) [static] This static method initializes static data for the SoGLModelMatrixElement class. Reimplemented from SoModelMatrixElement. Author Generated automatically by Doxygen for Coin from the source code. Version 3.1.3 Wed May 23 2012 SoGLModelMatrixElement(3)
All times are GMT -4. The time now is 09:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy