The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Paste a word in the third field position of a file girish.raos UNIX for Dummies Questions & Answers 1 08-17-2009 06:49 AM
To trim Certain field in a line of a file and replace the new string in that position rpadhi Shell Programming and Scripting 4 08-15-2009 11:03 AM
filtering records based on numeric field value in 8th position indusri Shell Programming and Scripting 2 07-10-2009 03:58 AM
how to find a position and print some string in the next and same position naveenkcl Shell Programming and Scripting 1 08-21-2008 01:18 PM
fill a NIL into the blank field happyv Shell Programming and Scripting 8 03-23-2007 04:49 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 4 Weeks Ago
ski ski is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 13
Unhappy Zero Fill 10 position field

Hi everyone, I am using shell scripting on a Unix SCO box. It calls a C program named zerofill. I do not know anything about C. I am having an issue with a hash total that should only be zero filled 10 positions but the record has 11 positions.
DEBUG RESULTS
Code:
+ nice -n -5 bc -l /tmp/fhash8395
FileHash=12010862188
+ nice -n -5 /u/APS/bin/zerofill 10 12010862188
FileHash=12010862188
+ nice -n -5 /u/APS/bin/zerofill 08 0000004
BatchCount=00000004
+ echo 90000040001340000000412010862188000030858737000000000000 – the 9 record has 11 positions instead of 10 This hash total should be 2010862188 dropping the leading 1.
This is the C code which I do not know how to read. Can anyone help to see if this is my issue? Thanks.
Code:
#include <stdio.h>
#include <stdlib.h>
main(int argc, char *argv[]) {
        int size;
        if (argc != 3) usage(argv[0]);
        size = atoi(argv[1]);
        printf("%0*s",size,argv[2]);
}
usage(char *s) {
        fprintf(stderr,"usage: %s size string\n",s);
        exit(1);
}

Last edited by pludi; 4 Weeks Ago at 04:43 PM.. Reason: code tags, please...
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:07 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0