Sponsored Content
Top Forums Programming random array index returning values not contained Post 302278614 by shamrock on Tuesday 20th of January 2009 04:39:14 PM
Old 01-20-2009
Better to use what Franklin52 suggested instead of setting all locations to NULL with memset.
 

10 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

why the inode index of file system starts from 1 unlike array index(0)

why do inode indices starts from 1 unlike array indexes which starts from 0 its a question from "the design of unix operating system" of maurice j bach id be glad if i get to know the answer quickly :) (0 Replies)
Discussion started by: sairamdevotee
0 Replies

2. UNIX for Dummies Questions & Answers

wh inode index starts from 1 unlike array index (0)

brothers why inode index starts from 1 unlike array inex which starts from 0 its a question from the design of unix operating system of maurice j.bach i need to know the answer urgently...someone help please (1 Reply)
Discussion started by: sairamdevotee
1 Replies

3. UNIX for Advanced & Expert Users

sql variable as array index

hi folks i am facing problom while trying to access sql variable as array index ina unix shell script....script goes as below.. #!/bin/ksh MAX=3 for elem in alpha beeta gaama do arr=$elem ((x=x+1)) Done SQL_SERVER='servername' /apps/sun5/utils/sqsh -S $SQL_SERVER -U user -P pwd -b -h... (1 Reply)
Discussion started by: sudheer157
1 Replies

4. Shell Programming and Scripting

awk array index help

$ cat file.txt A|X|20 A|Y|20 A|X|30 A|Z|20 B|X|10 A|Y|40 Summing up $NF based on first 2 fields, $ awk -F "|" 'BEGIN {OFS="|"} { sum += $NF } END { for (f in sum) print f,sum } ' file.txt o/p: A|X|50 A|Y|60 A|Z|20 (4 Replies)
Discussion started by: uwork72
4 Replies

5. Shell Programming and Scripting

dynamic index for array in while loop

Hi, I'm just trying to use a dynamic index for some array elements that I'm accessing within a loop. Specifically, I want to access an array at variable position $counter and then also at location $counter + 1 and $counter + 2 (the second and third array positions after it) but I keep getting... (0 Replies)
Discussion started by: weak_code-fu
0 Replies

6. Programming

FORTRAN -Returning index fir which values fall in a region

I have an 10 element array containing numbers, I want the start and end index in the array for which the values lie between DIST1 and DIST2. It is not working quite right. I also might want a value of 0 if I cannot find an index. V=(/10.0,20.0,30.0,40.0,50.0,60.0,70.0,80.0,90.0,100.0/) ... (4 Replies)
Discussion started by: kristinu
4 Replies

7. Shell Programming and Scripting

awk multiply values contained in 2 different files

Hi Everyone ! I have two files with the same configuration and I want to multiply corresponding values and write the result in a file. Let say 2 header lines and then lines of values (with not constant number of columns): more file1.txt --> BLABLABLA BLABLABLA 1 2 3 4 1 2 3 1 2 1... (7 Replies)
Discussion started by: Youm
7 Replies

8. Programming

Returning char array

I want to return a char array to the main() function, but its returning garbage value. #include<stdio.h> //#include<conio.h> #include<string.h> char* strtrmm(); int main() { char str1,c1; printf("\n Enter the string:"); gets(str1); //strtrmm(str1); printf("%s",strtrmm(str1));... (2 Replies)
Discussion started by: zinat
2 Replies

9. Shell Programming and Scripting

Associative array index question

I am trying to assign indexes to an associative array in a for loop but I have to use an eval command to make it work, this doesn't seem correct I don't have to do this with regular arrays For example, the following assignment fails without the eval command: #! /bin/bash read -d "\0" -a... (19 Replies)
Discussion started by: Riker1204
19 Replies

10. Shell Programming and Scripting

Copy of array by index value fails

Hello, I have a complicated situational find and replace that I wrote in bash because I didn't know how to do everything in awk. The code works but is very slow, as expected. To create my modified file, I am looping through an array that was populated earlier and making some replacements at... (6 Replies)
Discussion started by: LMHmedchem
6 Replies
memccpy(3)						     Library Functions Manual							memccpy(3)

NAME
memccpy, memchr, memcmp, memcpy, memmove, memset - Perform memory operations LIBRARY
Standard C Library (libc.so, libc.a) SYNOPSIS
#include <string.h> void *memccpy( void *s1, const void *s2, int c, size_t n); void *memchr( const void *s, int c, size_t n); int memcmp( const void *s1, const void *s2, size_t n); void *memcpy( void *s1, const void *s2, size_t n); void *memmove( void *s1, const void *s2, size_t n); void *memset( void *s, int c, size_t n); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: memchr(), memcmp(), memcpy(), memmove(), memset(): ISO C, XPG4, XPG4-UNIX memccpy(): XPG4, XPG4-UNIX Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Points to the location of a string. Points to the location of a destination string. Points to the location of a source string. Specifies a character for which to search (except for memset(), in which c is the target of the copy). Specifies the number of characters to search. DESCRIPTION
The memccpy(), memchr(), memcmp(), memcpy(), memmove(), and memset() functions operate on strings in memory areas. A memory area is a group of contiguous characters bound by a count and not terminated by a null character. These memory functions do not check for overflow of the receiving memory area. All of the functions are declared in the string.h header file. The memccpy() function sequentially copies bytes from the location pointed to by the s2 parameter into the location pointed to by the s1 parameter until one of the following occurs: The character specified by the c parameter, which is converted to an unsigned char, is copied. The number of characters specified by the n parameter has been copied to the string at location s1. The memccpy() function returns a pointer to the character that follows character c in the string pointed to by s1. If character c is not encountered after n characters have been copied to the string at location s1, this function returns a null pointer. The memchr() function returns a pointer to the first occurrence of character (byte) c in the string pointed to by s. If character c is not encountered after n bytes have been copied to the string at location s, this function returns a null pointer. The memcmp() function compares the first n characters (bytes), which are converted to unsigned char, of the string pointed to by the s1 parameter with the first n characters (also interpreted as unsigned char) of the string pointed to by the s2 parameter. The memcmp() function returns 0 (zero) or a nonzero value to indicate the results of the comparison operation. The sign of a nonzero value is determined by the sign of the difference between the values of the first pair of bytes that differ in the strings being compared. Possi- ble return values and their meanings follow: When s1 is less than s2 When s1 is equal to s2 When s1 is greater than s2 The memcpy() function copies n bytes from the string pointed to by the s2 parameter into the location pointed to by the s1 parameter. When copying overlapping strings, the behavior of this function is unreliable. The memmove() function copies n bytes from the string at the location pointed to by the s2 parameter to the string at the location pointed to by the s1 parameter. Copying takes place as though the n number of bytes from string s2 were first copied into a temporary location having n bytes that do not overlap either of the strings pointed to by s1 and s2. Then, n number of bytes from the temporary location is copied to the string pointed to by s1. Consequently, this operation is nondestructive and proceeds from left to right. The memset() function copies the value of the byte specified by the c parameter, which is converted to an unsigned char, into each of the first n locations of the string pointed to by the s parameter. RETURN VALUES
The memccpy() function returns a pointer to the byte following the character (byte) specified by the c parameter in the string pointed to by the s1 parameter. If character c is not found after the number of bytes specified by the n parameter are scanned, the function returns a null pointer. The memchr() function returns a pointer to the character (byte) specified by the c parameter. If character c does not occur after n bytes in the string pointed to by the s parameter are scanned, the function returns a null pointer. The memcmp() function returns a value greater than, equal to, or less than 0 (zero), according to whether the string pointed to by the s1 parameter has a value greater than, equal to, or less than the string pointed to by the s2 parameter. The memcpy() and memmove() functions return the string pointed to by the s1 parameter. No return value is reserved to indicate an error. The memset() function returns the string pointed to by the s parameter. RELATED INFORMATION
Functions: bcopy(3), string(3), swab(3), wmemcpy(3) Standards: standards(5) delim off memccpy(3)
All times are GMT -4. The time now is 06:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy