08-30-2011
Passing Pointers by reference in C++ Problem
Hello All,
I am having this issue...where I am actually having hard time understanding the problem:
The code is as follows:
HTML Code:
#include<iostream.h>
void fxn(char*** var)
{
int i =4;
*var = (char**)malloc(i*sizeof(char*));
for(int j =0; j<4; j++)
{
*var[j] = "name";
cout<<*var[j];
}
}
int main()
{
char** var;fxn(&var);
}
Am getting warning at line " *var[j] = "name" ": deprecated conversion from string constant to 'char*''
I know am doing something wrong......bt. can't seem to figure out what!
Thanks n Regards,
Last edited by mind@work; 09-15-2011 at 02:39 PM..
10 More Discussions You Might Find Interesting
1. Programming
Hello all,
I'm working on a small wrapper library for a bigger project, and i've been killing my self over (what I think is) a pointer problem.
Here is the code (I extracted the part of the code where the problem is for better reading, I tested the code below, and I get the same problem):... (13 Replies)
Discussion started by: tmp0
13 Replies
2. Programming
Dear friends,
can anybody pls tell me how to pass FILE pointer in c. I am so confused .. :confused:
suppose I ve two function
1. file_open()
2. read_line()
I want to call these function from main() function and in file_open() function it will open that file and in read_line()... (5 Replies)
Discussion started by: user_prady
5 Replies
3. Programming
Hi All,
I am using the array of pointers and storing the address of string.This is a global list.
So i am using extern to give the reference of this list to another file and using reading the data from this string.
But list is being corrupted and string is missing some characters in... (2 Replies)
Discussion started by: lovevijay03
2 Replies
4. Shell Programming and Scripting
i have a variable MYHOST that has my host name.depending on the host i have an array like A_<hostname>.Everytime i need to append the hostname to A_ to get the array.but in the shell script i am nt able to access the members of that array.
code of what i hav done:
export temp=A_$MYHOST
for... (15 Replies)
Discussion started by: niteesh_!7
15 Replies
5. Shell Programming and Scripting
I've made a habit of including a four-letter "tail" on image file names I download from the Web, so I can both match them with IPTC Transmission References of my own making and rename them later using either a GUI renamer or a script I've written myself. Now I want to automate the process of... (2 Replies)
Discussion started by: SilversleevesX
2 Replies
6. Programming
Hi guys.
What is the difference between these:
1. int *a;
2. int (*a); (2 Replies)
Discussion started by: majid.merkava
2 Replies
7. Shell Programming and Scripting
I got two files right now, input file (target file), reference file 1 (query file)
reference file 1 (long list of data)
KOLOPWMOPOPO
ADASDASD
ADSASDASDAD
.
.
target file (one long liner content)
ADASDASDTYUKOKOLOPWMOPOPOOPLUAADSASDASDADPOPOUYADADASDASD
desired output file content
... (1 Reply)
Discussion started by: patrick87
1 Replies
8. Homework & Coursework Questions
Hi, i'm trying to copy a struct into a binary file using the unix instruction write, so i declare and fill the struct "superbloque" in one function "initSB" and then i pass the pointer to another function called bwrite (for block write) which calls write. The problem is that i call the function... (2 Replies)
Discussion started by: ignatius3
2 Replies
9. Programming
Hello All,
I have a question in the following sample code:
If I am passing a reference of a variable, will the dynamic allocation happen in which it is passed?
Will the dynamic allocation will actually change the memory contents of char array "arr"?
int main()
{
char *arr;
... (1 Reply)
Discussion started by: mind@work
1 Replies
10. Shell Programming and Scripting
Here is the question...
Create a new script, sub2, taking three parameters...
1.) the string to be replaced
2.) the string with which to replace it
3.) the name of the file in which to make the substitution
...that treats the string to be replaced as plain text instead of as a regular... (1 Reply)
Discussion started by: johnhisenburg
1 Replies
LEARN ABOUT LINUX
motd.tail
MOTD.TAIL(5) Debian Administrator's Manual MOTD.TAIL(5)
NAME
motd.tail - Template for building the system message of the day
DESCRIPTION
On Debian systems, the system message of the day is rebuilt at each startup, in order to display an accurate information. /etc/motd.tail is
the file to edit permanent changes to the message of the day.
OVERVIEW
The initiation script /etc/init.d/bootmisc.sh prepends a line containing information about the system to /etc/motd.tail and stores the
resulting file in /var/run/motd. /etc/motd is a symbolic link to /var/run/motd. This is done to prevent changes to /etc as the system can
not assume /etc to be writable.
Changes to /etc/motd effectively end up in a file under /var/run which will be regenerated upon reboot.
A symbolic link to a different file, such as /etc/motd.static disables this behaviour.
FILES
/etc/init.d/bootmisc.sh
The initiation script which builds /var/run/motd
/etc/motd
Symbolic link to the system message of the day at /var/run/motd
/etc/motd.tail
Template for building the system message of the day
/var/run/motd
System message of the day file rebuilt at each computer start
SEE ALSO
login(1), issue(5), motd(5).
Debian 2007-04-28 MOTD.TAIL(5)