this is weird i tried a function it works and doesnt work so weird for example this code
Code:
#include <stdio.h>
#include <string.h>
#define DEL_IT(P,N)P[N]=0
void copy_it(char *buffer,char *save_it,int num)//num will be the i
{
int i,x;
for(i=num,x=0;save_it[x]=buffer[i];i++,x++);
}
int main(void)
{
char name[]="dude\nhell";
char buffer[100];
int i;
for(i=0;name[i]!=0;i++){
if(name[i]=='\n')
{
copy_it(name,buffer,i);
DEL_IT(name,i);
strcat(name," ");
strcat(name,buffer);
}
}
puts(name);
puts(buffer);
getchar();
return 0;
}
doesnt work
but this does
Code:
#include <stdio.h>
#include <string.h>
#define DEL_IT(P,N)P[N]=0
void copy_it(char *buffer,char *save_it,int num)//num will be the i
{
int i,x;
for(i=num,x=0;save_it[x]=buffer[i];i++,x++);
}
int main(void)
{
char name[]="dude\nhell";
char buffer[100];
int i;
for(i=0;name[i]!=0;i++){
if(name[i]=='\n')
{
copy_it(name,buffer,i);
DEL_IT(name,i);
strcat(name," ");
strcat(name,"HELL");
}
}
puts(name);
puts(buffer);
getchar();
return 0;
}
wat the hell is wrong ????