01-25-2011
Quote:
Originally Posted by
DreamWarrior
As far as Linux is concerned, it seems any quoted string in a source file is immutable
There's a gcc option to let you write to strings, but this is generally considered a bad idea anyway.
10 More Discussions You Might Find Interesting
1. Programming
$ gcc -Wall -Werror struct.c
struct.c: In function `main':
struct.c:18: error: dereferencing pointer to incomplete type
$ cat struct.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*Declaration of structure*/
struct human
{
char *first;
char gender;
int age;
} man,... (3 Replies)
Discussion started by: amit4g
3 Replies
2. UNIX for Dummies Questions & Answers
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
3. Solaris
Hi,
I have checked the net and can't find why I can't ping the server nor can I ping any address inside or outside the network from the server (using serial connection). I can set up DHCP on the server and it gets an address of 192.168.1.118 and everything is fine. I cannot ping anything from... (10 Replies)
Discussion started by: sunfan
10 Replies
4. Red Hat
Hello everey one,
here i am attempting to compile a c++ project .it's throughing the following errors.
my machine details are as follows:
Linux chmclozr0119 2.6.18-53.el5 #1 SMP Wed Oct 10 16:34:19 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux
errors:
=====
Generating... (0 Replies)
Discussion started by: mannam srinivas
0 Replies
5. Programming
N00B here. This function would be easier using a char pointer along with free. But I wish to learn how to use char static pointers (they do not require free, right ?).
How do I erase the content of a static pointer ? Terminating the string works but the static pointer's content is not being... (4 Replies)
Discussion started by: limmer
4 Replies
6. Programming
Is it permitted to type-cast a member variable passed in as a parameter in a member const method ..
I am doing something like :
in a
return-type method () const {
variable other = long(member variable)
}
this other assigned variable is not updating and I wonder if type-casting in such... (1 Reply)
Discussion started by: shriyer123
1 Replies
7. Programming
Hi,
from the manual
listen(2): listen for connections on socket - Linux man page
It has a parameter called backlog and it limits the maximum length of queue of pending list.
If I set backlog to 128, is it means no more than 128 packets can be handled by server?
If I have three... (3 Replies)
Discussion started by: sehang
3 Replies
8. Programming
if i declare both but don't input any variables what values will the int array and file pointer array have on default, and if i want to reset any of the elements of both arrays to default, should i just set it to 0 or NULL or what? (1 Reply)
Discussion started by: omega666
1 Replies
9. Programming
Hi,
Why I am getting 'SIGSEGV' in the following code?
char* p="abcde";
printf("%s", 3); // Segmentation Fault (core dump)
Kindly help me to understand what exactly makes the program to crash or the reason for the crashing. (7 Replies)
Discussion started by: royalibrahim
7 Replies
10. Programming
I have a uint8_t *C = malloc(24*sizeof(uint8_t));
I need to send some integers and this *C to another node(in ad hoc network). So I am going to use a struct
` struct fulMsg {
int msgType;
int msgCount;
//uint8_t *CC;
} fulMsg_t;
typedef struct fulMsg fulMsg_tt;`
there is a method... (1 Reply)
Discussion started by: chap
1 Replies
LEARN ABOUT DEBIAN
ao_string_tokenize
ao_string_tokenize(3) Programmer's Manual ao_string_tokenize(3)
NAME
ao_string_tokenize - tokenize an input string
SYNOPSIS
#include <your-opts.h>
cc [...] -o outfile infile.c -lopts [...]
token_list_t* ao_string_tokenize(char const* string);
DESCRIPTION
This function will convert one input string into a list of strings. The list of strings is derived by separating the input based on white
space separation. However, if the input contains either single or double quote characters, then the text after that character up to a
matching quote will become the string in the list.
The returned pointer should be deallocated with free(3C) when are done using the data. The data are placed in a single block of allocated
memory. Do not deallocate individual token/strings.
The structure pointed to will contain at least these two fields:
tkn_ct The number of tokens found in the input string.
tok_list An array of tkn_ct + 1 pointers to substring tokens, with the last pointer set to NULL.
There are two types of quoted strings: single quoted (') and double quoted ("). Singly quoted strings are fairly raw in that escape char-
acters () are simply another character, except when preceding the following characters:
double backslashes reduce to one
' incorporates the single quote into the string
0fP suppresses both the backslash and newline character
Double quote strings are formed according to the rules of string constants in ANSI-C programs.
string string to be tokenized
RETURN VALUE
pointer to a structure that lists each token
ERRORS
NULL is returned and errno will be set to indicate the problem:
EINVAL - There was an unterminated quoted string.
ENOENT - The input string was empty.
ENOMEM - There is not enough memory. @end itemize
EXAMPLES
#include <stdlib.h>
int ix;
token_list_t* ptl = ao_string_tokenize(some_string)
for (ix = 0; ix < ptl->tkn_ct; ix++)
do_something_with_tkn(ptl->tkn_list[ix]);
free(ptl);
Note that everything is freed with the one call to free(3C).
SEE ALSO
The info documentation for the -lopts library.
configFileLoad(3), optionFileLoad(3), optionFindNextValue(3), optionFindValue(3), optionFree(3), optionGetValue(3), optionLoadLine(3),
optionNextValue(3), optionOnlyUsage(3), optionProcess(3), optionRestore(3), optionSaveFile(3), optionSaveState(3), optionUnloadNested(3),
optionVersion(3), pathfind(3), strequate(3), streqvcmp(3), streqvmap(3), strneqvcmp(3), strtransform(3),
2011-07-10 ao_string_tokenize(3)