Sponsored Content
Full Discussion: urgent advice needed - gcc
Top Forums Programming urgent advice needed - gcc Post 302238300 by a.k.aFireknight on Friday 19th of September 2008 01:36:30 PM
Old 09-19-2008
urgent advice needed - self replication

what does the statement :

static char a[100] = "a";

store in the executable image. ??

I need to make a command line parameter exist AFTER the program finishes execution.. so that when i run the code next time ( without recompiling ).. i can work with the paramter..

for example:

$./prog pipe
>hello

$./prog tyre
>pipe

$./prog foo
>pipe


Also, i dont want to store it in another file.. maybe i could write a copy of prog in memory..

I hope u got what i wanna do ..

basically how to make

int main()
{ static char a[100[]="hello";
printf("%s",a);
}

to print pipe instead of hello... i think thats what static does.. but does it remember values even when prog execution ends.. i doubt that Smilie

Last edited by a.k.aFireknight; 09-20-2008 at 06:25 PM.. Reason: apt title
 

10 More Discussions You Might Find Interesting

1. Linux

programming advice needed....

i'm a grad student taking a UNIX course and a networks course (i have a background in C++ and JAVA). i'm trying to combine the two classes. My questions stems from a networks programming homework assignment below: "Using the operating system and language of your choice, develop a program to... (5 Replies)
Discussion started by: trostycp
5 Replies

2. Solaris

Using San storage - advice needed

Thinking of using our San for network backups.. Have a Netra 240 being installed and planning to get some space on our San. Do you know what software is used to access the San from my server or what I would need to do? I know how to connect to local storage, disk arrays etc but not sure what... (1 Reply)
Discussion started by: frustrated1
1 Replies

3. Cybersecurity

Want Urgent career Advice

Dear All, I have finished my MS in chemical engineering from US university and presetly on OPT work permit. I do not have software background. I have received call from consultant company. They are offering me AIX UNIX training for four weeks and find me a job. My question is how difficuilt... (0 Replies)
Discussion started by: saarth_desh
0 Replies

4. UNIX for Dummies Questions & Answers

Want URGENT Advice:Career as UNIX Systme Administrator

Dear All, I have finished my MS in chemical engineering from US university and presetly on OPT work permit. I do not have software background. I have received call from consultant company. They are offering me AIX UNIX training for four weeks and find me a job. My question is how difficuilt... (5 Replies)
Discussion started by: saarth_desh
5 Replies

5. Shell Programming and Scripting

'for' loop advice needed ....!!

/usr/sbin/ifconfig -a | grep "inet" | grep -v "inet6" | grep -v "127.0.0.1" | grep -v "0.0.0.0"|grep -v "192.168.100.2" | awk '{print $2}' I use above command to get IP addresses on AIX boxes.Values coming here are set to a variable "Host IPs.IP Addresses" in my fingerprinting engine. ... (4 Replies)
Discussion started by: ak835
4 Replies

6. Shell Programming and Scripting

Advice needed on using Script with NOHUP

All, I would like to know my below requirement can be achieved in any way in Shell Scripting? I will make this requirement of mine as understandable as I can. Requirement: I wrote a script 'my.script' which gets user-input tablenames and puts the same into an array. Also I get other inputs... (6 Replies)
Discussion started by: bharath.gct
6 Replies

7. UNIX for Advanced & Expert Users

'for' loop advice needed....!!

Scenario: Command used to capture IPs on a host: /usr/sbin/ifconfig -a | grep "inet" | egrep -v "inet6|0.0.0.0|192.168.100.2" | awk '{print $2}' Following for loop used to capture interface names: for INTERFACE in `/usr/sbin/ifconfig -a | nawk '$1 ~ /:$/ && $1 {sub(":$", "", $1); print... (3 Replies)
Discussion started by: ak835
3 Replies

8. Linux

Scripting advice needed

Evening all, Im trying to get a script that will: Select the most 3 recent files in a specific directory Run a command on them (like chmod) Ask of you would like to continue Copy the files to another directory If a linux guru could help me out, it would be very much appreciated. Thanks... (2 Replies)
Discussion started by: Wiggins
2 Replies

9. UNIX for Advanced & Expert Users

Expertise advice required <<URGENT>>

:eek:i hav a shell script in my linux server, i want to execute it everyday once automatically without using cron tabs as i dont hav permission to create one. So wht sld i do??:confused: (1 Reply)
Discussion started by: Jay Thakkar
1 Replies

10. Solaris

Solaris Study Advice Needed

I just have a question regarding learning Solaris, I have a Linux and AIX background and I would like to learn Solaris, I have been giving some Solaris 10 Study Guides and just wondered how relevant they would be to Solaris 11 or should I try and get some study materials which are targeted towards... (1 Reply)
Discussion started by: markmorris182mx
1 Replies
BACKTRACE(3)						     Linux Programmer's Manual						      BACKTRACE(3)

NAME
backtrace, backtrace_symbols, backtrace_symbols_fd - support for application self-debugging SYNOPSIS
#include <execinfo.h> int backtrace(void **buffer, int size); char **backtrace_symbols(void *const *buffer, int size); void backtrace_symbols_fd(void *const *buffer, int size, int fd); DESCRIPTION
backtrace() returns a backtrace for the calling program, in the array pointed to by buffer. A backtrace is the series of currently active function calls for the program. Each item in the array pointed to by buffer is of type void *, and is the return address from the corre- sponding stack frame. The size argument specifies the maximum number of addresses that can be stored in buffer. If the backtrace is larger than size, then the addresses corresponding to the size most recent function calls are returned; to obtain the complete backtrace, make sure that buffer and size are large enough. Given the set of addresses returned by backtrace() in buffer, backtrace_symbols() translates the addresses into an array of strings that describe the addresses symbolically. The size argument specifies the number of addresses in buffer. The symbolic representation of each address consists of the function name (if this can be determined), a hexadecimal offset into the function, and the actual return address (in hexadecimal). The address of the array of string pointers is returned as the function result of backtrace_symbols(). This array is malloc(3)ed by backtrace_symbols(), and must be freed by the caller. (The strings pointed to by the array of pointers need not and should not be freed.) backtrace_symbols_fd() takes the same buffer and size arguments as backtrace_symbols(), but instead of returning an array of strings to the caller, it writes the strings, one per line, to the file descriptor fd. backtrace_symbols_fd() does not call malloc(3), and so can be employed in situations where the latter function might fail. RETURN VALUE
backtrace() returns the number of addresses returned in buffer, which is not greater than size. If the return value is less than size, then the full backtrace was stored; if it is equal to size, then it may have been truncated, in which case the addresses of the oldest stack frames are not returned. On success, backtrace_symbols() returns a pointer to the array malloc(3)ed by the call; on error, NULL is returned. VERSIONS
backtrace(), backtrace_symbols(), and backtrace_symbols_fd() are provided in glibc since version 2.1. CONFORMING TO
These functions are GNU extensions. NOTES
These functions make some assumptions about how a function's return address is stored on the stack. Note the following: * Omission of the frame pointers (as implied by any of gcc(1)'s nonzero optimization levels) may cause these assumptions to be violated. * Inlined functions do not have stack frames. * Tail-call optimization causes one stack frame to replace another. The symbol names may be unavailable without the use of special linker options. For systems using the GNU linker, it is necessary to use the -rdynamic linker option. Note that names of "static" functions are not exposed, and won't be available in the backtrace. EXAMPLE
The program below demonstrates the use of backtrace() and backtrace_symbols(). The following shell session shows what we might see when running the program: $ cc -rdynamic prog.c -o prog $ ./prog 3 backtrace() returned 8 addresses ./prog(myfunc3+0x5c) [0x80487f0] ./prog [0x8048871] ./prog(myfunc+0x21) [0x8048894] ./prog(myfunc+0x1a) [0x804888d] ./prog(myfunc+0x1a) [0x804888d] ./prog(main+0x65) [0x80488fb] /lib/libc.so.6(__libc_start_main+0xdc) [0xb7e38f9c] ./prog [0x8048711] Program source #include <execinfo.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> void myfunc3(void) { int j, nptrs; #define SIZE 100 void *buffer[100]; char **strings; nptrs = backtrace(buffer, SIZE); printf("backtrace() returned %d addresses ", nptrs); /* The call backtrace_symbols_fd(buffer, nptrs, STDOUT_FILENO) would produce similar output to the following: */ strings = backtrace_symbols(buffer, nptrs); if (strings == NULL) { perror("backtrace_symbols"); exit(EXIT_FAILURE); } for (j = 0; j < nptrs; j++) printf("%s ", strings[j]); free(strings); } static void /* "static" means don't export the symbol... */ myfunc2(void) { myfunc3(); } void myfunc(int ncalls) { if (ncalls > 1) myfunc(ncalls - 1); else myfunc2(); } int main(int argc, char *argv[]) { if (argc != 2) { fprintf(stderr, "%s num-calls ", argv[0]); exit(EXIT_FAILURE); } myfunc(atoi(argv[1])); exit(EXIT_SUCCESS); } SEE ALSO
gcc(1), ld(1), dlopen(3), malloc(3) COLOPHON
This page is part of release 3.44 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. GNU
2008-06-14 BACKTRACE(3)
All times are GMT -4. The time now is 05:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy