Hello so i don't have any friends who could help me i get this eror when i test this code look what i have already done
./main "Hello World!" "ld"
-bash: !": event not found
what is this what is happening
here is the main :
#include <stdio.h>
#include <err.h>
#include <string.h>
int main (int argc, char *argv[])
{
int p = 0;
int q = 1;
int place = 0;
int check = 0;
char position[10] = ""; // i think the error is here
while (argv[1][p] != '\0')
{
if (argv[1][p] == argv[2][0])
{
place = p;
while (argv[2][q] != '\0' && argv[1][p + q] != '\0' && argv[2][q] == argv[1][p + q])
{
q += 1;
}
if (argv[2][q] == '\0')
{
check = 1;
printf("%s\n", argv[1]); //i think the error is here
for (int n = 0; n < place; n += 1) //i think the error is here
{
strcat(position, " "); //i think the error is here
}
strcat(position, "^"); //i think the error is here
printf("%s\n", position); //i think the error is here
}
}
p += 1;
}
if (check == 0)
{
printf("Not found!\n");
}
return 0 ; // return 0
}
I added comment so you can maybe help
and also how can I create
char position[10] = "";
without giving the length I tried
char position[] = "";
but it doesn't compile