02-28-2002
I thought that this was just a crazy thread. But I just typed:
echo 22 | dd conv=ebcdic | od -x
and sure enough a character 2 in ebcdic is a F2. But if this is supposed to be a conversion to ebcdic, this isn't really converging on a solution. Still, it might be an attempt at displaying what the bytes would be in ebcdic or something.
The lack of itoa always bothered me a little too. It seems like such an obvious companion to atoi. But it's not there, so I agree that sprintf is the general solution.
If you're absolutely sure that "i" contains an integer less than 100, this might be quick:
msd=i/10;
lsd=i%10;
printf("F%dF%d\n", msd, lsd);
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
I'm trying to compile and install both most recent version of 'make' and the
most recent version of 'openssh' on my Sparc20.
I've run into the following problems... and I don't know what they mean. Can
someone please help me resolve these issues?
I'm using the 'make' version that was... (5 Replies)
Discussion started by: xyyz
5 Replies
2. Shell Programming and Scripting
Hello,
Just a little problem with the ksh function : strlen
I want to use this function in this little ksh program :
while read line ; do
TOTO=$line
TOTONB=strlen($TOTO)
echo $TOTONB (3 Replies)
Discussion started by: steiner
3 Replies
3. UNIX for Dummies Questions & Answers
Hi
how can i do this?
1) shell script which writes data and time on to a file if filesystem exceeds 70% of space.
2) make entry to cron table to run a script every 15 mins.
and can anyone expplain or demonstrate the difference between variables used in inside a function and outside a... (3 Replies)
Discussion started by: vivekshankar
3 Replies
4. Programming
In a declaration, I have:
const char comment_begin = "<!--";
const char comment_end = "-->";
const int comment_begin_len = strlen(comment_begin);
const int comment_end_len = strlen(comment_end);
When I compile, I get the warnings:
emhttpc.c:64: warning: initializer element is not... (10 Replies)
Discussion started by: cleopard
10 Replies
5. Programming
I have been getting some flack recently for my use of strlen() and strnlen(). Honestly I have always just taken their functionality for granted as being the easiest way of getting the length of a string. Is it really so much better to do pointer arithmetic? What am I gaining besides more... (3 Replies)
Discussion started by: jjinno
3 Replies
6. UNIX for Dummies Questions & Answers
Hello,
I am having problems with using less on
Linux version 2.6.18-92.1.17.el5 (brewbuilder@hs20-bc1-7.build.redhat.com) (gcc version 4.1.2 20071124 (Red Hat 4.1.2-42)). I am using csh but have the same problems on bash.
If I pipe something to less it works perfectly i.e. cat file | less... (9 Replies)
Discussion started by: z1dane
9 Replies
7. Programming
My OS (Debian) and gcc use the UTF-8 locale. This code says that the char size is 1 byte but the size of 'a' is really 4 bytes.
int main(void)
{
setlocale(LC_ALL, "en_US.UTF-8");
printf("Char size: %i\nSize of char 'a': %i\nSize of Euro sign '€': %i\nLength of Euro sign: %i\n",... (8 Replies)
Discussion started by: cyler
8 Replies
8. Shell Programming and Scripting
#! /bin/bash
# ask what the user would like to do
CMD=$CMD
MBA=$MB
RS=$RS
CT=$CT
echo
echo -n "What would you like to do??
REMEMBER WHEN PROGRAMMING ICP's TO SELECT CORRECT COMMAND ACCORDING TO
NECCESSARY TYPE CODE!
Please enter a command
ct = program ctek
... (5 Replies)
Discussion started by: tdalyman
5 Replies
9. Programming
Hello,
This function was copied into my code, which was compiled without error/warning, but when executed there is always Segmentation fault at the end after the output (which seems correct!):
void get_hashes(unsigned int hash, unsigned char *in)
{
unsigned char *str = in;
int pos =... (7 Replies)
Discussion started by: yifangt
7 Replies
10. Shell Programming and Scripting
greetings,
pretty new to php and i think i might be missing some fundamental limitation of isset. i have two php scripts below that are executed by crond, one using --host X and one that does not. and below that are three different attempts at generating a command line that will be executed. the... (8 Replies)
Discussion started by: crimso
8 Replies
strlen(3) Library Functions Manual strlen(3)
NAME
strlen - Finds the length of a string
LIBRARY
Standard C Library (libc.so, libc.a)
SYNOPSIS
#include <string.h>
size_t strlen( const char *s);
STANDARDS
Interfaces documented on this reference page conform to industry standards as follows:
strlen(): ISO C, XPG4
Refer to the standards(5) reference page for more information about industry standards and associated tags.
PARAMETERS
Specifies the string.
DESCRIPTION
The strlen() function returns the number of bytes in the string pointed to by the s parameter. The string length value does not include the
terminating null character.
Note
If you pass a NULL pointer as the const char * parameter to the strlen function, the function generates a segmentation violation. To avoid
the segmentation violation and cause the function to return 0 (zero), change the NULL pointer treatment for the process before issuing the
call to the strlen function, as follows: Include the system header file sys/uswitch.h. Call the uswitch function, as described in the
uswitch(2) reference page.
The following program illustrates this procedure:
#include <stdio.h> #include <sys/types.h> #include <sys/uswitch.h>
main() {
size_t retval;
int uswitch_val;
uswitch_val = uswitch(USC_GET,0);
uswitch(USC_SET, uswitch_val | USW_NULLP);
retval = strlen(NULL);
RETURN VALUES
On successful completion, the strlen() function returns the number of characters (bytes) in the string to which the s parameter points.
Current industry standards specify that no value be reserved to indicate an error.
RELATED INFORMATION
Functions: string(3), uswitch(2), wcslen(3)
Standards: standards(5) delim off
strlen(3)