Sponsored Content
Full Discussion: char array
Top Forums Programming char array Post 78474 by avadhani on Wednesday 20th of July 2005 01:16:32 AM
Old 07-20-2005
char array

hi,
I have variable like,
char keyword[17] = "TRANSPARENCY ";

while passing this variable to some function, first character of variable becomes null, but rest of characters still exist. Why this happens or something wrong with declaration. Their is no error while compiling & running program (cc: Sun WorkShop 6 update 2 C 5.3)

singnature of function is like
getVal(char *keyword, int *val);

thanking you,
 

9 More Discussions You Might Find Interesting

1. Programming

char array problem

hello i have a program in C (Unix - SOlaris5.7), and i have the next question: i have a lot of char variable, and i want store their values in a char array. The problem is what i donīt know how to put the char variable's value into the array, and i don`t know how to define the array please... (4 Replies)
Discussion started by: DebianJ
4 Replies

2. Programming

size of char array in c

i have to store a data more than 100000. i don't know the size of the data whether it may be 100000 or 1000000. so how can i define variable size; example char abc; but i don't know the size so how can i give array size?? in one sentence how can i give the array size dynamically so that i... (6 Replies)
Discussion started by: phani_sree
6 Replies

3. Programming

CHAR Array - stuffed with values - with more size than it holds

Hi All I am simulating a problem in the production where i faced a situation. Please find the following example program which i simulated. #include<stdio.h> #include<stdlib.h> #include<string.h> int main() { char str1; (3 Replies)
Discussion started by: dhanamurthy
3 Replies

4. Programming

Passing by value a char array

Hi I am passing or want to pass value of a char array, so that even thoug the called routine is changing the values the calling function should not see the values changed, meaning only copy should be passed Here is the program #include<iostream.h> #include<string.h> void f(char a); int... (5 Replies)
Discussion started by: rkraj
5 Replies

5. Programming

Array of char

I'm doing some coding in C++ Want to have a long empty string like below const char ModMisfit :: DelStr = "\r \r"; However due to the long blank the line is very long. Is there any way to avoid this and keep the... (5 Replies)
Discussion started by: kristinu
5 Replies

6. Programming

help with char pointer array in C

i have an array like #define NUM 8 .... new_socket_fd = accept(socket_fd, (struct sockaddr *) &cli_addr, &client_length); char *items = {"one", "two", "three", "four", "five", "six", "seven", "eight"}; char *item_name_length = {"3", "3", "5", "4", "4", "3", "5", "5"}; ... (1 Reply)
Discussion started by: omega666
1 Replies

7. Programming

char array

cat int.c int main() { unsigned char wwn; wwn=50; wwn=00; wwn=53; wwn=30; wwn=08; wwn=09; wwn=82; wwn=17; printf("WWN: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n ", wwn, wwn, wwn, wwn, wwn,... (8 Replies)
Discussion started by: powyama
8 Replies

8. Shell Programming and Scripting

How do I test the first char of each line in an array

Hi folks, I am self-learning as I can I have a script that has read a file into an array. I can read out each line in the array with the code: for INDEX in {0..$LENGTH} ## $LENGTH was determined at the read in do echo "${data}" done What I need to do is test the first char... (2 Replies)
Discussion started by: Marc G
2 Replies

9. 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
GETENV(9)						   BSD Kernel Developer's Manual						 GETENV(9)

NAME
freeenv, getenv, getenv_int, getenv_long, getenv_string, getenv_quad, getenv_uint, getenv_ulong, setenv, testenv, unsetenv -- kernel environ- ment variable functions SYNOPSIS
#include <sys/param.h> #include <sys/systm.h> void freeenv(char *env); char * getenv(const char *name); int getenv_int(const char *name, int *data); int getenv_long(const char *name, long *data); int getenv_string(const char *name, char *data, int size); int getenv_quad(const char *name, quad_t *data); int getenv_uint(const char *name, unsigned int *data); int getenv_ulong(const char *name, unsigned long *data); int setenv(const char *name, const char *value); int testenv(const char *name); int unsetenv(const char *name); DESCRIPTION
These functions set, unset, fetch, and parse variables from the kernel's environment. The getenv() function obtains the current value of the kernel environment variable name and returns a pointer to the string value. The call- er should not modify the string pointed to by the return value. The getenv() function may allocate temporary storage, so the freeenv() function must be called to release any allocated resources when the value returned by getenv() is no longer needed. The env argument passed to freeenv() is the pointer returned by the earlier call to getenv(). The setenv() function inserts or resets the kernel environment variable name to value. If the variable name already exists, its value is replaced. This function can fail if an internal limit on the number of environment variables is exceeded. The unsetenv() function deletes the kernel environment variable name. The testenv() function is used to determine if a kernel environment variable exists. It returns a non-zero value if the variable name exists and zero if it does not. The getenv_int(), getenv_long(), getenv_quad(), getenv_uint(), and getenv_ulong() functions look for a kernel environment variable name and parse it as a signed integer, long integer, signed 64-bit integer, unsigned integer, or an unsigned long integer, respectively. These func- tions fail and return zero if name does not exist or if any invalid characters are present in its value. On success, these function store the parsed value in the integer variable pointed to by data. If the parsed value overflows the integer type, a truncated value is stored in data and zero is returned. If the value begins with a prefix of ``0x'' it is interpreted as hexadecimal. If it begins with a prefix of ``0'' it is interpreted as octal. Otherwise, the value is interpreted as decimal. The value may contain a single character suffix specify- ing a unit for the value. The interpreted value is multipled by the unit's magnitude before being returned. The following unit suffixes are supported: Unit Magnitude k 2^10 m 2^20 g 2^30 t 2^40 The getenv_string() function stores a copy of the kernel environment variable name in the buffer described by data and size. If the variable does not exist, zero is returned. If the variable exists, up to size - 1 characters of it's value are copied to the buffer pointed to by data followed by a null character and a non-zero value is returned. RETURN VALUES
The getenv() function returns a pointer to an environment variable's value on success or NULL if the variable does not exist. The setenv() and unsetenv() functions return zero on success and -1 on failure. The testenv() function returns zero if the specified environment variable does not exist and a non-zero value if it does exist. The getenv_int(), getenv_long(), getenv_string(), getenv_quad(), getenv_uint(), and getenv_ulong() functions return a non-zero value on success and zero on failure. BSD
October 22, 2013 BSD
All times are GMT -4. The time now is 05:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy