Basically, the copy string function is supposed to copy 1 string to another. The output for both strings is Hello World! Why does this actually work though because I am only passing in the value of these strings? I'm not passing by reference or anything.
My second question is why do I have to include string.h but not iostream.h? Why does the .h part only have to be there to include the string header file? Why is iostream so special it doesn't need a .h extension?
#include <iostream>
#include <string.h>
void copyString(char[] stringToCopyTo, char[] stringToCopy);
int main(){
char string1[] = "Hello World!";
char string2[80];
copyString(string2, string1);
std::cout << "String1: " << string1 << "\n";
std::cout << "String2: " << string2 << "\n";
return 0;
}
void copyString(char stringToCopyTo[], char stringToCopy[]){
stringToCopyTo = stringToCopy;
}