it's kind of hard to tell, you have
int merge(char str1[], int index1,char str2[],int index2, char result[], int index3);
int merge_strings(char str1[], int index1,char str2[],int index2, char...
Type: Posts; User: melight
it's kind of hard to tell, you have
int merge(char str1[], int index1,char str2[],int index2, char result[], int index3);
int merge_strings(char str1[], int index1,char str2[],int index2, char...
again what exactly you need to do with those two? You need to check while copying? Or you can first check, then copy (or vice versa)?
that's easy, in the second string copy the '\0' in to the result array also, and only then return
You should be checking which string you are copying right now
if(str1[index1]=='\0')
{
return index1;
}
else
{
result[index1]=str1[index1];
you simply need to cat two strings? lets say "abc" merged with "bcd" will be "abcbcd", right?
Do you absolutely have to use recursion to do that?
What exactly do you mean by 'merge'?
Tried that out, easier than I first assumed :D
The library must be static, not sure it's an issue here though.
Another thing I'd like to ask: can I hide functions in the library from the...
Well, to be frank, both. Never done either. Thats why I want to see a basic example from which I can start rolling
I don't even know if it makes any sense. Our sadist professor gave us this last exercise for this term. We should write a library that reassembles ip fragments (the fragmentation will be simulated...
Ok, thanx a lot everyone, I got it working, a function which replaces patt1 with patt2 in a given string and changes it's size if needed. It also takes care of special cases - empty second pattern,...
there you go:
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
char* strreplace(char *str, char *patt, char *repl);
Note taken, doesn't really fix my problem though (I've cut down the actual code where I do free() to something readable and relevant) .
I've tried both things you've suggested laserlight, but...
Going to check that out now
yeap, I want the function to change the string I am passing to it (which SHOULD be happening, coz I'm passing a pointer). The alg goes like this:
while occurrence of patt found in str {
...
Hi, first post here :D
I'm writing a program in C on Linux (Ubuntu) for a school project, one of the modules of the program is getting two arguments (patt and repl) and is also taking lines from...