Sponsored Content
Full Discussion: Using const char*
Top Forums Programming Using const char* Post 302684139 by hergp on Thursday 9th of August 2012 07:56:01 AM
Old 08-09-2012
desc is not a constant pointer to char, but a pointer to a constant char.

If you want desc to be a constant pointer, write:
Code:
char * const desc;

If you want desc to be a constant pointer to a constant character, write:
Code:
 const char * const desc;

 

10 More Discussions You Might Find Interesting

1. Programming

Reference to a const

Can any one explain how the statement '2' in the following statements is a legal one. int & ref = 3; // Illegal statement - Compiler error. const int& ref=3 ; // Compile and executes properly. Thanks in Advance, Arun (1 Reply)
Discussion started by: arun.viswanath
1 Replies

2. Programming

diff b/w char const in C/C++

hi, what is the difference b/w char in C and C++.and give me the examples. Thanks... sarwan (3 Replies)
Discussion started by: sarwan
3 Replies

3. UNIX for Dummies Questions & Answers

int open(const char *pathname, int flags, mode_t mode) doubt...

hello everybody! I want to create a file with permissions for read, write, and execute to everybody using C, so I write this code: #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int main(){ int fileDescriptor; fileDescriptor =... (2 Replies)
Discussion started by: csnmgeek
2 Replies

4. Programming

Adding a single char to a char pointer.

Hello, I'm trying to write a method which will return the extension of a file given the file's name, e.g. test.txt should return txt. I'm using C so am limited to char pointers and arrays. Here is the code as I have it: char* getext(char *file) { char *extension; int i, j;... (5 Replies)
Discussion started by: pallak7
5 Replies

5. Programming

concat const char * with char *

hello everybody! i have aproblem! i dont know how to concatenate const char* with char const char *buffer; char *b; sprintf(b,"result.txt"); strcat(buffer,b); thanx in advance (4 Replies)
Discussion started by: nicos
4 Replies

6. Programming

Optional non-const reference argument c++ ?

Is it possible to have a non-const reference variable as an OPTIONAL/DEFAULT parameter to c++ function ex void read(string &data,int &type=0 /*or something*/) ; so i will call read(data); //or int type; read(data,type); printf("Type =%d",type); I found one dirty workaround ... (2 Replies)
Discussion started by: johnbach
2 Replies

7. Programming

Questions about const

Hi all, I have some questions about functions. In a code I have (a .hpp file) there is this line which says: const Class_1_Name* Class_2_Name::MethodName(int ipart) const {return (ClassName*)_ref_to_method.At(ipart);} My questions are: What is the meaning of the two constants,... (2 Replies)
Discussion started by: eager2no
2 Replies

8. Programming

Why this const variable is not changing even after applying const_cast?

Hi In the following code, why the variable 'i' still retains the value 10 instead of 11? Why it is not possible to alter this variable's value? int main() { const int i = 10; *(const_cast<int*>(&i)) = 11; cout << i << endl; // Ans: 10 } (6 Replies)
Discussion started by: royalibrahim
6 Replies

9. Programming

error: invalid conversion from ‘const char*’ to ‘char*’

Compiling xpp (The X Printing Panel) on SL6 (RHEL6 essentially): xpp.cxx: In constructor ‘printFiles::printFiles(int, char**, int&)’: xpp.cxx:200: error: invalid conversion from ‘const char*’ to ‘char*’ The same error with all c++ constructors - gcc 4.4.4. If anyone can throw any light on... (8 Replies)
Discussion started by: GSO
8 Replies

10. Programming

Double to const char conversion

Dear all, I am using C and ROOT for programming. And I need to incorporate following in my code. char *fps=NULL; int dec=0,sign=0; float mean = h1->GetMean(1); //0.001298 fps= fcvt(mean,6 , &dec, &sign); I need to provide this mean as const char to some other function to get... (8 Replies)
Discussion started by: emily
8 Replies
atReadExpand(3) 					       AtFS Toolkit Library						   atReadExpand(3)

NAME
atOpenExpand, atReadExpand, atCloseExpand - read version objects with attribute citations expanded atGetWriteName - get bound version name of a version object opened with atOpenExpand SYNOPSIS
#include <atfs.h> #include <atfstk.h> int atOpenExpand(char *version, int expand_busy) ; int atReadExpand(int desc, char *bufp, int nbytes) ; void atCloseExpand(int desc) ; char *atGetWriteName(int desc) ; extern int atBindError ; extern char atBindErrorMsg[] ; DESCRIPTION
atOpenExpand, atReadExpand, and atCloseExpand are designed as a nearly plug-compatible replacement for the system calls open(2), read(2), and close(2) for reading of AtFS version objects with attribute citations expanded. atOpenExpand opens the file or AtFS version object version for reading with atReadExpand. Version points to the pathname of a file or AtFS version object. If the flag expand_busy is non-zero, attribute citations are expanded in busy versions also. atOpenExpand returns a descriptor that is valid as argument to successive calls to atReadExpand and atCloseExpand. atReadExpand attempts to read nbytes of data from the object referenced by the descriptor desc into the buffer pointed to by bufp. If desc is zero, atReadExpand reads from the standard input. atReadExpand returns the number of bytes actually read. atCloseExpand frees the resources associated with the descriptor desc. atGetWriteName returns a pointer to the bound version name of the version object for which atOpenExpand returned the descriptor desc. DIAGNOSTICS
On error atOpenExpand and atReadExpand return -1 and set errno appropriately. If one of these returns an error and errno is set to ENOMEM, the application may retry the operation, possibly after freeing some memory. If atOpenExpand returns an error and atBindError has a non-zero value, the string version did not select a version object or not a unique version object. In this case atBindErrorMsg contains an appropriate error message. Possible Values of errno after a call to atOpenExpand: ENOMEM Not enough memory could be allocated. EMFILE All available descriptors are in use. All errno values returned by open(2) or read(2). Possible Values of errno after a call to atReadExpand: ENOMEM Not enough memory could be allocated. EBADF Invalid descriptor. BUGS
Since atOpenExpand reads the complete contents of version into memory, it fails on very large version objects. SEE ALSO
intro(2), open(2), read(2), close(2), errno(3), atattribute(3), atbind(3). AtFStk-1.12 Tue Feb 16 20:33:25 1993 atReadExpand(3)
All times are GMT -4. The time now is 04:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy