05-07-2013
argv is an array of pointers to arrays of char, so first think of it at char**, something that needs one dereferencing ( * or [#] ) to get to char*, which C uses as string. The actual rules for argv is that the last element is a null pointer, so you can size it somewhat analagous to strlen(). The argc is just for your convenience, provided by the loader. char** could be char[][] which is a 2 dimensional heap of characters locally, but the name would still need dereferencing. Since printf's '%s' demands a char*, one layer of dereferencing is right. Another way to think of '*' is '[0]', so **argv is the first char of argv[0], is argv[0][0]. Array names are of type type* even if the array is local, but local arrays have size of the array not size of a pointer. So, 'char *x = "Y" ;' is a local pointer variable initialized with a pointer size 4 to a constant string, two hunks of storage, but 'char x[] = "Y" ;' is a local array size 2 of characters Y and null (sized implicitly by the initializer), one small hunk of storage, and there is no pointer storage, just an array name that is always a pointer.
Last edited by DGPickett; 05-07-2013 at 04:35 PM..
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
say I have a IP address which is 10.0.0.12, and subnet mask is 255.255.255.240, what is the network address and what is the broadcast address which host lives on?
And could you explain how to get the answer?
thanx in advance! (7 Replies)
Discussion started by: pnxi
7 Replies
2. IP Networking
Hi sir,
i want to make such programe which takes MAC(Ethernet) address of any host & give me its IP address.......
but i'm nt getting that how i can pass the MAC address to Frame........
Please give me an idea for making such program...
Thanks & regards
Krishna (3 Replies)
Discussion started by: krishnacins
3 Replies
3. Programming
How do I get a pointer to any 32 bit address on my hard drive, in which I then could read that memory or write to that memory address?
And, while the subject is on, how do get a 32 bit pointer in RAM also, in which I can do the same?
I'm using C and Objective-C with gcc on an iBook G4.
A... (9 Replies)
Discussion started by: xcoder66
9 Replies
4. Programming
Hi i'm new to c programming and i'm trying to change the address of a pointer/variable but i can't seem to get it right,
I have this
char heap;
char *firstFree = heap;
char *allocMem( int size ) {
void *malloc(size_t sizeofint);
/*allocate space for an array with size... (19 Replies)
Discussion started by: Poison Ivy
19 Replies
5. Programming
If one wants to get a start address of a array or a string or a block of memory via a function, there are at least two methods to achieve it:
(1) one is to pass a pointer-to-pointer parameter, like:
int my_malloc(int size, char **pmem)
{
*pmem=(char *)malloc(size);
if(*pmem==NULL)... (11 Replies)
Discussion started by: aaronwong
11 Replies
6. Shell Programming and Scripting
Trying to do a ksh script that needs to list all ip address between ip address a and b ..
ie.
Ip address A=192.168.1.200
Ip address B=192.168.2.15
So the subnet changes from 1 to 2 but I want to list all possible ip addresses between the 2..
Which would be:
192.168.1.200... (4 Replies)
Discussion started by: frustrated1
4 Replies
7. UNIX for Dummies Questions & Answers
:) Firstly Hi all!!, im NEW!! and on here hoping that someone might be able to offer me some help... i have a server that keeps crashing every few days with the error message:
PANIC KERNAL-MODE ADDRESS FAULT ON USER ADDRESS 0X14
KERNAL PAGE FAULT FROM (CS:EIP)=(100:EF71B5BD)
EAX=EF822000... (10 Replies)
Discussion started by: Twix
10 Replies
8. IP Networking
Hi there
I lost connectivity to one of our remote systems and when I checked the messages log I found the following:
Aug 10 23:42:34 host xntpd: time reset (step) 1.681729 s
Aug 16 13:20:51 host ip: WARNING: node "mac address" is using our IP address x.x.x.x on aggr1
Aug 16 13:20:51 host... (9 Replies)
Discussion started by: notreallyhere
9 Replies
9. UNIX for Dummies Questions & Answers
How can I print the memory address of a pointer using printf (or any other STDOUT functions?). I see in Linux its %p but not in unix, help?
thanks (5 Replies)
Discussion started by: perleo
5 Replies
10. UNIX for Advanced & Expert Users
Hi ,
Could someone let me know how to detect duplicate ip address after assigning ip address to ethernet interface using c program (3 Replies)
Discussion started by: Gopi Krishna P
3 Replies
LEARN ABOUT SUSE
tcl_joinpath
Tcl_SplitPath(3) Tcl Library Procedures Tcl_SplitPath(3)
__________________________________________________________________________________________________________________________________________________
NAME
Tcl_SplitPath, Tcl_JoinPath, Tcl_GetPathType - manipulate platform-dependent file paths
SYNOPSIS
#include <tcl.h>
Tcl_SplitPath(path, argcPtr, argvPtr)
char *
Tcl_JoinPath(argc, argv, resultPtr)
Tcl_PathType
Tcl_GetPathType(path)
ARGUMENTS
const char *path (in) File path in a form appropriate for the current platform (see the filename manual entry for
acceptable forms for path names).
int *argcPtr (out) Filled in with number of path elements in path.
const char ***argvPtr (out) *argvPtr will be filled in with the address of an array of pointers to the strings that are the
extracted elements of path. There will be *argcPtr valid entries in the array, followed by a
NULL entry.
int argc (in) Number of elements in argv.
const char *const *argv (in) Array of path elements to merge together into a single path.
Tcl_DString *resultPtr (in/out) A pointer to an initialized Tcl_DString to which the result of Tcl_JoinPath will be appended.
_________________________________________________________________
DESCRIPTION
These procedures have been superceded by the objectified procedures in the FileSystem man page, which are more efficient.
These procedures may be used to disassemble and reassemble file paths in a platform independent manner: they provide C-level access to the
same functionality as the file split, file join, and file pathtype commands.
Tcl_SplitPath breaks a path into its constituent elements, returning an array of pointers to the elements using argcPtr and argvPtr. The
area of memory pointed to by *argvPtr is dynamically allocated; in addition to the array of pointers, it also holds copies of all the path
elements. It is the caller's responsibility to free all of this storage. For example, suppose that you have called Tcl_SplitPath with the
following code:
int argc;
char *path;
char **argv;
...
Tcl_SplitPath(string, &argc, &argv);
Then you should eventually free the storage with a call like the following:
Tcl_Free((char *) argv);
Tcl_JoinPath is the inverse of Tcl_SplitPath: it takes a collection of path elements given by argc and argv and generates a result string
that is a properly constructed path. The result string is appended to resultPtr. ResultPtr must refer to an initialized Tcl_DString.
If the result of Tcl_SplitPath is passed to Tcl_JoinPath, the result will refer to the same location, but may not be in the same form.
This is because Tcl_SplitPath and Tcl_JoinPath eliminate duplicate path separators and return a normalized form for each platform.
Tcl_GetPathType returns the type of the specified path, where Tcl_PathType is one of TCL_PATH_ABSOLUTE, TCL_PATH_RELATIVE, or TCL_PATH_VOL-
UME_RELATIVE. See the filename manual entry for a description of the path types for each platform.
KEYWORDS
file, filename, join, path, split, type
Tcl 7.5 Tcl_SplitPath(3)