Sponsored Content
Top Forums Programming Help understanding pointer assignment in c Post 302363257 by HeavyJ on Monday 19th of October 2009 09:28:17 PM
Old 10-19-2009
broli,

C does not hide memory pointer information.

"asdf" is a "string literal."

when initializing a char*, "asdf" is seen by the program as a pointer to that location in memory.

The same is not true for other basic types.

int *Bogus = { 0, 1, 2, 3, 4}; - does not work
int Correct[5] = { 0, 1, 2, 3, 4}; does work

malloc() allocates memory on a global heap, and requires a type cast.
using [] allocates memory locally, and the size of this chunk is limited, so don't use brackets for really big arrays.

Two operators will come in handy all the time... "*" and "&"
 

10 More Discussions You Might Find Interesting

1. Programming

pointer

void main() { int a={1,2,3,4,5,6,7,8,9,10}; int *p=a; int *q=&a; cout<<q-p+1<<endl; } The output is 10, how? if we give cout<<q it will print the address, value won't print.... if we give cout<<p it will print the address, value won't print.... p has the base addr; q... (1 Reply)
Discussion started by: sarwan
1 Replies

2. Programming

far pointer

what is far pointer in C (1 Reply)
Discussion started by: useless79
1 Replies

3. What is on Your Mind?

New Assignment

All Sys Administrators, With due respect I would like to know what should be BEST Things to do when LEAVING one job , and what Precaution MUST be taken while taking over new JOB?? Please Discuss in detail the STEP to be taken for both the TIME ?? (3 Replies)
Discussion started by: vakharia Mahesh
3 Replies

4. Programming

pass a pointer-to-pointer, or return a pointer?

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

5. Homework & Coursework Questions

Assignment Help

1. List commands to create the directory hierarchy $HOME/a/b/c in vi to replace all occurences of TMP with tmp in lines 1 through 10 in vi to replace first occurence of CPU_file with DISK_file at line 15 2. Explain with a very simple example, usage of "ls -a" 3. What do the... (2 Replies)
Discussion started by: jessesaini
2 Replies

6. Shell Programming and Scripting

Help Assignment !! :D

Q-1 Write a shell script in Unix that lists files from your current working directory · By modification time when called with lm · By access time when called with la. By default, the script should show the listing of all the files in the current directory. Q-2 Write a... (1 Reply)
Discussion started by: Vishank Parikh
1 Replies

7. Homework & Coursework Questions

Help Assignment !! :D

Q-1 Write a shell script in Unix that lists files from your current working directory · By modification time when called with lm · By access time when called with la. By default, the script should show the listing of all the files in the current directory. Q-2 Write a shell script which... (1 Reply)
Discussion started by: Vishank Parikh
1 Replies

8. Programming

Understanding C++ template partial specialization with pointer datatype arguments

When I compile the below code, I am getting error as template<typename T> T AddFun(T i, T j) { return i + j; } template<> T* AddFun<T*>(T* i, T* j) { return new T(*i + *j); } int main() { int n = AddFun<int>(10, 20); int i = 10, j = 20; int* p = AddFun<int*>(&i,... (1 Reply)
Discussion started by: royalibrahim
1 Replies

9. Homework & Coursework Questions

Understanding Getopts in an otherwise easy assignment

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: In the command line I will be given files or words which will be USER ID's or a file of USER ID's. I am to let... (4 Replies)
Discussion started by: ByronicX
4 Replies

10. UNIX for Dummies Questions & Answers

Need a little help with assignment

Hello all im currently working on this assignment and a little stump on how to check for an argument heres the instructions: Step 4: Modify your script so that if there is an argument called TestError you display the following error message with your usage statement. TestError found Example:... (1 Reply)
Discussion started by: bsn3971
1 Replies
dbconfig-load-include(1)					  dbconfig-common					  dbconfig-load-include(1)

NAME
dbconfig-load-include - parse custom format db config files SYNOPSIS
dbconfig-load-include [-hv] [-a] [-d[varname]] [-u[varname]] [-p[varname]] [-s[varname]] [-P[varname]] [-t[varname]] -f format infile DESCRIPTION
dbconfig-load-include is a program to parse custom format include files containing the information necessary to connect a program to a database resource. This is primarily intended to be used by the dbconfig-common package to import database settings of packages with pre-existing configurations that have migrated to dbconfig-common. for more information, please see /usr/share/doc/dbconfig-common. OPTIONS
infile use the given config file as input -f|--format use the given output format (default: sh) -a|--all include all information in output (default) -d|--dbname include the dbname in the output -p|--dbpass include the dbpass in the output -s|--dbserver include the dbserver in the output -P|--dbport include the dbport in the output -u|--dbuser include the dbuser in the output -t|--dbtype include the dbtype in the output -h|--help display this helpful message -v|--version output the version and exit format is one of a list of include-file style formats for various programming languages. the current list includes: sh /bin/sh style include file perl perl parseable include file php php parseable include file exec run the file as a script and interpret its output sean finney March 2005 dbconfig-load-include(1)
All times are GMT -4. The time now is 01:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy