Sponsored Content
Full Discussion: String Constant C
Top Forums Programming String Constant C Post 302843880 by shamrock on Thursday 15th of August 2013 01:01:19 PM
Old 08-15-2013
Quote:
Originally Posted by kris26
For example,
Code:
int *pointer = "Hello, World";

Is the string constant available until the pointer variable as an automatic variable is discarded?
String literals are static objects so they are in existence as long as the program is running. As "pointer" is an automatic variable it is discarded upon exit from the block in which it is defined but the string literal will still be in memory but you wont have a handle for accessing it anymore. Automatic variables are on the stack segment while static objects are in the text segment or the readonly portion of the data segment and yes the compiler automatically allocates storage for them without the programmer having to do anything...
 

7 More Discussions You Might Find Interesting

1. Programming

'strlen' of a constant string

In a declaration, I have: const char comment_begin = "<!--"; const char comment_end = "-->"; const int comment_begin_len = strlen(comment_begin); const int comment_end_len = strlen(comment_end); When I compile, I get the warnings: emhttpc.c:64: warning: initializer element is not... (10 Replies)
Discussion started by: cleopard
10 Replies

2. Shell Programming and Scripting

Constant mirroring

I'm not sure how to best explain what I'd like to do, so let me give an example. I used to work in a department that deals with internet security. This department had an "internal" website (only people in the building can get on it) and an "external" website (anyone in the world can get on it --... (1 Reply)
Discussion started by: sstevens
1 Replies

3. Shell Programming and Scripting

choose random text between constant string.. using awk?

Hallo I have maybe a little bit advanced request.... I need to choose one random part betwen %.... so i have this.. % text1 text1 text1 text1 text1 text1 text1 text1 text1 % text2 text2 text2 text2 text2 % text3 text3 text3 tetx3 % this choose text between % awk ' /%/... (8 Replies)
Discussion started by: sandwich
8 Replies

4. Solaris

Constant disturbing messages????

Hi friends, I am new to Solaris, I have just managed to install Solaris 10 under VirtualBox. As I use the system, I constantly get some very disturbing error messages on my screen, I hope you will help me remove them. Messages are # syslogd: line 24: WARNING: loghost could not be resolved ... (6 Replies)
Discussion started by: gabam
6 Replies

5. Shell Programming and Scripting

Trouble appending string constant to variable

Hi. I define my variables as: month=jul DD=17 YEAR=2012 transmission_file_name_only=test_$month$DD$YEAR_partial.dat However when I run my script the variable 'transmission_file_name_only' resolves to: File "/downloads/test_jul17.dat" not found. How can I append this '_partial'... (3 Replies)
Discussion started by: buechler66
3 Replies

6. Shell Programming and Scripting

How to solve awk: line 1: runaway string constant error?

Hi All ! I am just trying to print bash variable in awk statement as string here is my script n=1 for file in `ls *.tk |sort -t"-" -k2n,2`; do ak=`(awk 'FNR=='$n'{print $0}' res.dat)` awk '{print "'$ak'",$0}' OFS="\t" $file n=$((n+1)) unset ak doneI am getting following error awk:... (7 Replies)
Discussion started by: Akshay Hegde
7 Replies

7. Debian

LM 17.3 xfce constant lagging

I'm using LM 17.3x LIVE. Have constant and sometimes, severe lagging issues. Problems started when I "upgraded" to 18.3x. I tried 5 other distros all with the same issues. Went back to 17.3 and , alas, the problem followed. Found this: sudo gedit /etc/sysctl. conf vm. swappiness = 15, but all it... (4 Replies)
Discussion started by: 69Rixter
4 Replies
MYSQLI_ERROR(3) 							 1							   MYSQLI_ERROR(3)

mysqli::$error - Returns a string description of the last error

       Object oriented style

SYNOPSIS
string$mysqli->error () DESCRIPTION
Procedural style string mysqli_error (mysqli $link) Returns the last error message for the most recent MySQLi function call that can succeed or fail. PARAMETERS
o $ link -Procedural style only: A link identifier returned by mysqli_connect(3) or mysqli_init(3) RETURN VALUES
A string that describes the error. An empty string if no error occurred. EXAMPLES
Example #1 $mysqli->error example Object oriented style <?php $mysqli = new mysqli("localhost", "my_user", "my_password", "world"); /* check connection */ if ($mysqli->connect_errno) { printf("Connect failed: %s ", $mysqli->connect_error); exit(); } if (!$mysqli->query("SET a=1")) { printf("Errormessage: %s ", $mysqli->error); } /* close connection */ $mysqli->close(); ?> Procedural style <?php $link = mysqli_connect("localhost", "my_user", "my_password", "world"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s ", mysqli_connect_error()); exit(); } if (!mysqli_query($link, "SET a=1")) { printf("Errormessage: %s ", mysqli_error($link)); } /* close connection */ mysqli_close($link); ?> The above examples will output: Errormessage: Unknown system variable 'a' SEE ALSO
mysqli_connect_errno(3), mysqli_connect_error(3), mysqli_errno(3), mysqli_sqlstate(3). PHP Documentation Group MYSQLI_ERROR(3)
All times are GMT -4. The time now is 09:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy