11-28-2008
#include <string.h>
int main()
{
char *seq1 = "eeeeeeeeeeeeeeeeee";
char *seq2 = "dddddddddddddddddddd";
const char* a = "*";
seq2=(char*)malloc(strlen(seq2)+1);
strcat(seq2,a);
printf("%s",seq2);
return 0;
}
10 More Discussions You Might Find Interesting
1. Programming
I have a class with an integer pointer, which I have not initialized to NULL in the constructor. For example:
class myclass
{
private:
char * name;
int *site;
}
myclass:: myclass(....)
: name(NULL)
{
.....
}
other member function “delete “ the variable before... (2 Replies)
Discussion started by: sureshreddi_ps
2 Replies
2. Programming
I received a warning when I tried to compile my program that said:
warning: comparison between pointer and integer
Could you please explain to me what this means, and in what ways I could possibly fix this?
Thanks for your help! (2 Replies)
Discussion started by: sjung10
2 Replies
3. Programming
strcat dumping core in the situation like
main()
{
char* item;
char* p=sat_item;
char type;
item=(char*) malloc(strlen(p));
strncpy(type,p,4);
type='\0';
strcat(item,type); //dumping core
}
I couldn't get why strcat dumping core? (3 Replies)
Discussion started by: satish@123
3 Replies
4. Shell Programming and Scripting
Hi all,
How does string concatenation work in shell scripting?
I basically have a variable called "string" and I want to add the strings "aaa" "bbb" "ccc" "ddd" to the variable "string". These strings would be added based on some conditions and separated by spaces . So "string" might look... (8 Replies)
Discussion started by: felixmat1
8 Replies
5. Programming
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
6. Programming
I use solaris10,following is tcp client code:
#include "cliserv.h"
int main(int argc,char argv){
struct sockaddr_in serv;
char request,reply;
int sockfd,n;
if(argc!=2)
err_quit("usage: tcpclient <IP address of server>");
if((sockfd=socket(PF_INET,SOCK_STREAM,0))<0)
... (1 Reply)
Discussion started by: konvalo
1 Replies
7. Programming
Anyone have any ideas why when using strcat function I would get some garbage at the beginning of the output string? what I'm doing is something like the following example.
Code:
char temp;
char tempHolder;
for(int i=0;i<something;i++){
sprintf(temp,"%u ", someVariable);... (2 Replies)
Discussion started by: airon23bball
2 Replies
8. Programming
Hi guys :D
I am still playing with my C handbook and yes, as you can see I have small problem as always :cool:
I wrote a C code
#include <stdio.h> #define MESSAGE 100 int main(void) { char input_mes - Pastebin.com
And when I try to compile it I get following errors from gcc
... (1 Reply)
Discussion started by: solaris_user
1 Replies
9. UNIX for Dummies Questions & Answers
I'm trying to write a programme which scans strings to find how many vowels they contain. I get an error saying that I'm trying to compare a pointer and an integer inif(*v == scanme){. How can I overcome this ? Also, the programme seems to scan only the first word of a string e.g.: if I type "abc... (1 Reply)
Discussion started by: fakuse
1 Replies
10. Programming
Hello,
#include <stdio.h>
#include <string.h>
void main()
{
char tab={"12"};
FILE *outfile;
char *outname = "/home/dir/";
printf("%s",strcat(outname,tab));
outfile = fopen(strcat(outname,tab), "w");
if (!outfile) {
printf("There was a problem opening %s for writing\n", outname);
... (2 Replies)
Discussion started by: chercheur857
2 Replies
LEARN ABOUT MOJAVE
algorithm::diffold5.18
Algorithm::DiffOld(3) User Contributed Perl Documentation Algorithm::DiffOld(3)
NAME
Algorithm::DiffOld - Compute `intelligent' differences between two files / lists but use the old (<=0.59) interface.
NOTE
This has been provided as part of the Algorithm::Diff package by Ned Konz. This particular module is ONLY for people who HAVE to have the
old interface, which uses a comparison function rather than a key generating function.
Because each of the lines in one array have to be compared with each of the lines in the other array, this does M*N comparisions. This can
be very slow. I clocked it at taking 18 times as long as the stock version of Algorithm::Diff for a 4000-line file. It will get worse
quadratically as array sizes increase.
SYNOPSIS
use Algorithm::DiffOld qw(diff LCS traverse_sequences);
@lcs = LCS( @seq1, @seq2, $comparison_function );
$lcsref = LCS( @seq1, @seq2, $comparison_function );
@diffs = diff( @seq1, @seq2, $comparison_function );
traverse_sequences( @seq1, @seq2,
{ MATCH => $callback,
DISCARD_A => $callback,
DISCARD_B => $callback,
},
$comparison_function );
COMPARISON FUNCTIONS
Each of the main routines should be passed a comparison function. If you aren't passing one in, use Algorithm::Diff instead.
These functions should return a true value when two items should compare as equal.
For instance,
@lcs = LCS( @seq1, @seq2, sub { my ($a, $b) = @_; $a eq $b } );
but if that is all you're doing with your comparison function, just use Algorithm::Diff and let it do this (this is its default).
Or:
sub someFunkyComparisonFunction
{
my ($a, $b) = @_;
$a =~ m{$b};
}
@diffs = diff( @lines, @patterns, &someFunkyComparisonFunction );
which would allow you to diff an array @lines which consists of text lines with an array @patterns which consists of regular expressions.
This is actually the reason I wrote this version -- there is no way to do this with a key generation function as in the stock
Algorithm::Diff.
perl v5.18.2 2006-07-30 Algorithm::DiffOld(3)