0
need a help, needed to solve this programming language exercise, would concatenate a string, in case STRING_B in STIRNG_A, without use of ready function, by pointer method.
example:
ENTRADAS >> "CASA " - "BAHIA"
SAIDA >> CASA BAHIA
follows the code...
#include <stdio.h>
#include <string.h>
/*escreva uma funcao em c que recebe a referencia de duas strings e concatena
a segunda na primeira sem usar funcao strcat()*/
void ptr(char *string_a, char *string_b)
{
int i;
do{
string_a++;
}while(*string_a!='\0');
do{
string_a=*string_b;
string_b++;
}while(*string_b!='\0');
}
int main (void)
{
char string_a[250];
char string_b[250];
puts(" -- DIGITE UMA PALAVRA -- ");
gets(string_a);
puts(" -- DIGITE UMA PALAVRA -- ");
gets(string_b);
ptr(string_a,string_b);
puts(string_a);
return 0;
}
Error] 'for' loop initial declarations are only allowed in C99 or C11 mode; submitted this error!
– AGenaro
@Agenaro I do not know why the error, but so do with while even, I edited my answer.
– Francisco
@Francisso Now it worked ! Thanks. only in the code you sent last missed Point and comma after '++i'
– AGenaro