How can I solve error C2374 in Visual C ++ ?
Error C2374 : redefinition ,multiple initialization
#include<iostream>
#include<cstring>
using namespace std;
int main (void)
{
char str1[10]="Ali",str2[10]="Bassim" ;
int i;
i=strcmp(str1,str2);
char str2[10]="Ali";
i=strcmp(str1,str2);
char str1[10]="Dany";
i=strcmp(str1,str2);
return 0;}
You've declared str1 and str2 as a char arrays twice. Omit the "char" the second time str2[10] = "Ali";
str1[10] = "Dany";But that's still not going to work, because now you're trying to assign character arrays (strs) to chars (str2[10] is a char). You need:
strcpy(str2, "Ali");
strcpy(str1, "Dany");It should then compile OK. But it's still not going to do anything; you need to print the value of "i" each time to see what is happening.
oh thank you very much , this was really helpful = )
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |