Hello. I need to write a program that prints the length of a string; however, I cannot use the <string> or <string.h> libraries. The directions are to: 1) Write a StringLength () function 2) Declare and initialize the string 3) Pass the string to StringLength () and 3) Print the length of a string. This is the code I have, but I keep getting the error message: "24|error: invalid conversion from 'char' to 'std::basic_istream<char>::char_type* {aka char*}' [-fpermissive]|" on the following line: "cin.getline(x, 199);" I have no idea what I am doing wrong. Thank you for any help!
Your problem (for both of you) is that you are passing a char, rather than a pointer to char (C-String). That is also what is causing the error for the OP (before getting to the linker error of no implementation for StringLength). Try to have this declaration instead:
int StringLength(constchar* x); // Takes a C-String
@bigorenski shows one way of doing that function, I won't repeat it here.