I'm really brand new to C++ and I'm currently learning it for fun. I'm working on prototype functions, and I got an error I can't figure out!
I get an error saying “warning : '<' : signed/unsigned incompatibility” but I haven't defined an unsigned int anywhere. Actually, I don't even really know much about them except that they allow bytes from -127 to 127 instead of 0 to 256 for signed int's if I understood correctly...
The function itself is supposed to make a pointer go to the end of a string and add the Null Byte at the end. There's probably an already-existing way to do so, but I don't know it. Plus it is fun making this.
In the below code I'll be making comments for most lines so you may correct me if I'm not doing what I think I am.
Anyway, here's the code of my "my_fct.h" header file :
#include <stdio.h> //Includes basic functions necessary in C as 'scanf' or 'printf'.
#include <string.h> //Includes string functions such as 'strcpy' or 'strcmp'.
#include <iostream> //Not sure about what this does.
int strend(char); /* Specifies the existence of a function 'strend' that uses a char
* string as argument and that returns a value of integer type. */
char string; //Declares a global string called 'string'.
int strend(char string) /* Declares a function that uses the global string 'string'
* as argument. */
char *pointer=string; //Declares a pointer '*pointer' that points to 'string'.
for (i=0 ; i<strlen(string) ; i++) /* Repeat as many times as the number of
* characters of 'string'. */
*pointer++; //'Pointer' points to the character next to the one it was pointing.
*pointer='\0'; //Adds the null byte after the 'for' loop is ended.
return 0; //If the function was successful, return the value '0'.