11-10-2005
The OP put up another post after this - my take is that he doesn't know very much about C and has been asked to fix somebody else's mess. You'll notice there is a missing semi-colon in the post as well.
What he wanted was a way to offset by one byte that starting point of strcat & strcpy source string.
8 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I am working on a script that prompts a user name and creates a list in a username.dat file. Furthermore, I have created a sorted_username.dat file. My question is this: My script uses the word "finished" != finished to break the while loop. How can I avoid having the word "finished" show up in... (5 Replies)
Discussion started by: erest8
5 Replies
2. Shell Programming and Scripting
Hi All,
I want to remove last word from a line using Vi.
Do we have any vi command for that.
line : ss dd ff gg
i have to run some vi command which can delete gg from the line
Thanks,
Ravi Sadani (4 Replies)
Discussion started by: ravi.sadani19
4 Replies
3. Shell Programming and Scripting
Hi All,
In one of the sections in my perl script, I need to remove the 1st character of a word and store in an array.The details are ,
The original script was ,
if ( ! defined $inq{$node}{"dmx"} ) {
print "INFO: Collecting inq disk information for DMX array on $node.\n";
... (2 Replies)
Discussion started by: abhilash.pa
2 Replies
4. Shell Programming and Scripting
hi
I would like to ask if someone knows a command or a script on how to rename a multiple file in the directory starting at the end of the filename or at the .extension( i would like to remove the last 11 character before the extension) for example
Below is the result of my command ls inside... (5 Replies)
Discussion started by: jao_madn
5 Replies
5. Shell Programming and Scripting
Hello! This is my first post here.
I have a file with text like:
A</title>
B
C</title>
D
I need to format it to:
AB
CD
I am trying to use sed: sed 's/<//title>\n/ /g' file > newfile
to delete </title> and the newline character, but the file is unchanged because there are... (3 Replies)
Discussion started by: DaytonCPS
3 Replies
6. Shell Programming and Scripting
lets say i have a file named ex1 which contain an essay.
(a) delete the word "benefit" from the file
(b) delete the last 6 characters on each line
for the first problem i entered :g/benefit/d but it deletes the whole line
please help (3 Replies)
Discussion started by: koricha
3 Replies
7. Shell Programming and Scripting
It is very simple to remove a hyphen from a word anywhere in that word using a simple sed command (sed -i 's/-//g' filename), but I am not able to figure out how to do this:
For example,
apple
-orange
tree
pipe-
banana-shake
dupe-
What my output should look like:
apple
orange
tree... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies
8. Shell Programming and Scripting
My file has the entries like below...
/dev/sds
/dev/sdak
/dev/sdbc
/dev/sdbu
I want to make the file like below
echo 1 > /sys/block/sds/device/rescan
echo 1 > /sys/block/sdak/device/rescan
echo 1 > /sys/block/sdbc/device/rescan
echo 1 > /sys/block/sdbu/device/rescan (2 Replies)
Discussion started by: saravanapandi
2 Replies
LEARN ABOUT DEBIAN
dynarr
DYNARR(3pub) C Programmer's Manual DYNARR(3pub)
NAME
dynarr, dynarr_init, dynarr_resize, dynarr_free - simple dynamic arrays
SYNOPSIS
#include <publib.h>
void dynarr_init(struct dynarr *da, size_t elsize);
int dynarr_resize(struct dynarr *da, size_t newsize);
void dynarr_free(struct dynarr *da);
DESCRIPTION
These functions make it easier to use dynamic arrays, i.e., arrays that are allocated with malloc(3) and resized with realloc(3). Below is
a typical code fragment for implementing a dynamic array that is resized as more input is read.
char *p, *line;
size_t alloc, len;
len = 0;
alloc = 1024;
if ((line = malloc(alloc)) == NULL) abort();
while (fgets(line + len, alloc-len, stdin) != NULL) {
len = strlen(line);
alloc += 1024;
if ((p = realloc(alloc)) == NULL) abort();
alloc = p;
}
(The error handling is intentionally simplified.) Below is the above fragment with the dynarr(3).
struct dynarr da;
dynarr_init(&da);
while (fgets((char *)da.data + da.used, da.alloc-da.len, stdin) != NULL) {
da.used = strlen(da.data);
if (dynarr_resize(&da, da.alloc + 1024) == -1) abort();
}
The code is a bit simpler, and all the memory allocation details and most of the error checking code is hidden away.
The dynamic array is represented by a struct dynarr:
struct dynarr {
void *data;
size_t alloc, used;
};
The interface to the dynamic allocation has intentionally been made unopaque.
dynarr_init initializes a struct dynarr to be an empty array, dynarr_resize sets its size to be newsize, and dynarr_free frees the array
(it will become an empty array again).
RETURNS
dynarr_resize returns -1 if it failed, 0 if it succeeded. It does not change the array in any way if it failed.
SEE ALSO
publib(3), malloc(3), realloc(3), strdup(3)
AUTHOR
Lars Wirzenius (lars.wirzenius@helsinki.fi)
Publib C Programmer's Manual DYNARR(3pub)