09-20-2006
Thanks corona, It works fine.
I have one more doubt regarding sizeof(string).
For ex:- If I have code,
char func(char funcstr[12]){
printf("%d\n",sizeof(funcstr));
}
main() {
char mainstr[12];
func(mainstr);
printf("%d\n",sizeof(mainstr));
}
size of mainstr is giving the array size(i.e. 12),
whereas funcstr is giving the pointer size(i.e. 4),
will it not give the array size as we declared it as array ?
Thanks
10 More Discussions You Might Find Interesting
1. Programming
Hi All,
My main intension of is to convert the Hexstring stored in a char* into hex and then prefixing it with "0x" and suffix it with ','
This has to be done for all the hexstring char* is NULL.
Store the result prefixed with "0x" and suffixed with ',' in another char* and pass it to... (1 Reply)
Discussion started by: rvan
1 Replies
2. Shell Programming and Scripting
I am trying to match a character return from a website so that I can replace it. It is the '...' character (didnt even know it existed initially). The character apparently has the hex value of 2026, but in the script, attempting to substitute regular 3 periods is not working.
What am I... (2 Replies)
Discussion started by: Guyverix
2 Replies
3. Programming
Hello all. I need help...
How can I cenvert this 42ec93df826c804ea531c56594db453d54daad4b to normal text? What convertor I have to use?
Thanks. (12 Replies)
Discussion started by: escudo
12 Replies
4. Programming
I want it to ouput "abcd", but it dosen't.
1 #include<stdio.h>
2 int main()
3 {
4 printf("a\x62cd");
5 }
6
gcc alarm.c -o alarm
alarm.c: In function 'main':
alarm.c:4:9: warning: hex escape sequence out of range
It seems that the complier joint "cd" as part of... (8 Replies)
Discussion started by: vistastar
8 Replies
5. Shell Programming and Scripting
Hi Guys,
writing a small shell script, i need to convert parts of a string to "Hex". The problem is that it is not the full string that needs to be converted.
I think it's best to show an example:
$astring = "xxxxxx ABC+10+##########+DEF xxxx"
This is only an example to show how the... (9 Replies)
Discussion started by: HansHansen
9 Replies
6. Shell Programming and Scripting
i have this below string which i need to convert it to HEX. i have already tried it but it showing extra few things on it.. let me show what i have done and what is the output i am getting and what is the desired output
the input string is
"!\"\"\"\"\"\"\"!\"\"\"\"\"\"\""
which is... (4 Replies)
Discussion started by: vivek d r
4 Replies
7. Shell Programming and Scripting
I have this below string in a variable
cutString=21222222222222222122222222222222
this string is nothing but hex values depicted as below
21:22:22:22:22:22:22:22:21:22:22:22:22:22:22:22
so what i want to achieve is swap the lower order with higher order values in the... (3 Replies)
Discussion started by: vivek d r
3 Replies
8. Shell Programming and Scripting
Hi,
Anyone can help using SED searches a character string for a specified delimiter character, and returns a leading or trailing space/blank.
Text file :
"1"|"ExternalClassDEA519CF5"|"Art1"
"2"|"ExternalClass563EA516C"|"Art3"
"3"|"ExternalClass305ED16B8"|"Art9"
...
...
... (2 Replies)
Discussion started by: fspalero
2 Replies
9. Shell Programming and Scripting
I have a long string of hex (from ASN.1 data) where I need to find and change a particular hex value only and increment it. The hex pairs either side (84 and a7) of the value to increment will remain constant.
i.e. "84 <length> <value_to_increment> a7" starting with 00.
So end result:
... (11 Replies)
Discussion started by: securegooner
11 Replies
10. UNIX for Beginners Questions & Answers
Hi,
I'm looking to split the following hex string into rows of four elements.
I've tried the following but it doesn't seem to work. How can I tell sed to match based on a pair of number(s) and letter(s), and add a newline every 4 pairs?
In addition, I need to add another newline after every... (5 Replies)
Discussion started by: sand1234
5 Replies
LEARN ABOUT FREEBSD
lfind
LSEARCH(3) BSD Library Functions Manual LSEARCH(3)
NAME
lsearch, lfind -- linear search and append
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <search.h>
void *
lsearch(const void *key, void *base, size_t *nelp, size_t width, int (*compar)(const void *, const void *));
void *
lfind(const void *key, const void *base, size_t *nelp, size_t width, int (*compar)(const void *, const void *));
DESCRIPTION
The lsearch() and lfind() functions walk linearly through an array and compare each element with the one to be sought using a supplied com-
parison function.
The key argument points to an element that matches the one that is searched. The array's address in memory is denoted by the base argument.
The width of one element (i.e., the size as returned by sizeof()) is passed as the width argument. The number of valid elements contained in
the array (not the number of elements the array has space reserved for) is given in the integer pointed to by nelp. The compar argument
points to a function which compares its two arguments and returns zero if they are matching, and non-zero otherwise.
If no matching element was found in the array, lsearch() copies key into the position after the last element and increments the integer
pointed to by nelp.
RETURN VALUES
The lsearch() and lfind() functions return a pointer to the first element found. If no element was found, lsearch() returns a pointer to the
newly added element, whereas lfind() returns NULL. Both functions return NULL if an error occurs.
EXAMPLES
#include <search.h>
#include <stdio.h>
#include <stdlib.h>
static int
element_compare(const void *p1, const void *p2)
{
int left = *(const int *)p1;
int right = *(const int *)p2;
return (left - right);
}
int
main(int argc, char **argv)
{
const int array[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
size_t element_size = sizeof(array[0]);
size_t array_size = sizeof(array) / element_size;
int key;
void *element;
printf("Enter a number: ");
if (scanf("%d", &key) != 1) {
printf("Bad input0);
return (EXIT_FAILURE);
}
element = lfind(&key, array, &array_size, element_size,
element_compare);
if (element != NULL)
printf("Element found: %d0, *(int *)element);
else
printf("Element not found0);
return (EXIT_SUCCESS);
}
SEE ALSO
bsearch(3), hsearch(3), tsearch(3)
STANDARDS
The lsearch() and lfind() functions conform to IEEE Std 1003.1-2001 (``POSIX.1'').
HISTORY
The lsearch() and lfind() functions appeared in 4.2BSD. In FreeBSD 5.0, they reappeared conforming to IEEE Std 1003.1-2001 (``POSIX.1'').
BSD
April 21, 2013 BSD