08-13-2008
Taking the 'const' off gave the same results.
7 More Discussions You Might Find Interesting
1. Programming
hello,
i have a problem with strlen. I have written this:
for(y=13,z=0; cInBuf!=' ';y++)
{
cBuf=cInBuf;
z++;
}
len = strlen(cBuf);
out=len/2;
fprintf(outfile,"F%i",out);
If strlen is e.g. 22, it write F22. I want to write F2F2.
How can i do this?... (5 Replies)
Discussion started by: ACeD
5 Replies
2. Shell Programming and Scripting
Hallo
I have maybe a little bit advanced request....
I need to choose one random part betwen %....
so i have this..
%
text1 text1 text1
text1 text1 text1
text1 text1 text1
%
text2 text2
text2 text2 text2
%
text3 text3 text3
tetx3
%
this choose text between %
awk ' /%/... (8 Replies)
Discussion started by: sandwich
8 Replies
3. 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
4. Shell Programming and Scripting
Hi. I define my variables as:
month=jul
DD=17
YEAR=2012
transmission_file_name_only=test_$month$DD$YEAR_partial.dat
However when I run my script the variable 'transmission_file_name_only' resolves to:
File "/downloads/test_jul17.dat" not found.
How can I append this '_partial'... (3 Replies)
Discussion started by: buechler66
3 Replies
5. Shell Programming and Scripting
Hi All !
I am just trying to print bash variable in awk statement as string
here is my script
n=1
for file in `ls *.tk |sort -t"-" -k2n,2`; do
ak=`(awk 'FNR=='$n'{print $0}' res.dat)`
awk '{print "'$ak'",$0}' OFS="\t" $file
n=$((n+1))
unset ak
doneI am getting following error
awk:... (7 Replies)
Discussion started by: Akshay Hegde
7 Replies
6. Programming
I wonder string constant exists permanently or temporary.
For example,
printf("hello, world");
the function printf access to it is through a pointer. Does it mean storage is allocated for the string constant to exist permanently in memory? :confused: (4 Replies)
Discussion started by: kris26
4 Replies
7. 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
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)