jeudi 13 août 2015

Why is my program not compiling?

My code is suppose to initialise any word you type but it is refusing to compile . I don't understand the error messages it is giving to me.
1 initialize.c:24:23: error: incompatible integer to pointer conversion passing 'char' to parameter of type 'const char *'; take the address with & [-Werror,-Wint-conversion] 2 initialize.c:21:23: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]

3 initialize.c:21:23: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security] printf(toupper(s[i]));

#include <stdio.h>
#include<cs50.h>
#include<string.h>
#include<ctype.h>

void initialize(string s);
int main(int argc, string argv[])
{ 
     printf("May I have your name?");
     string name = GetString();
     initialize(name);

}
void initialize(string s)
{    
     int space = 1;

     for (int i = 0;i < strlen(s); i++)
     {     if(space == 1)
           {
               printf(toupper(s[i])); 
               space -= 1;
           }       
           if(strncmp(s[i]," ",1 ) )  
           {

                space += 1;         

           }
     }


}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire