Click here to Skip to main content
15,074,377 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
This is my code
C++
#include <stdio.h>
int main(){
char Name="Daniel";
printf("Hello My Name Is %s",Name);
}
:

This is my error:
warning: initialization makes integer from pointer without a cast [-Wint-conversion]|

What I have tried:

I have tried stackoverflow,I have also looked all over google but couldnt find the awnser.I also tried quora
Posted
Updated 8-Dec-19 3:28am

Rick is right but you need to add a
C++
return 0;
at the end of main function!!!

Visit some tutorial like Learn C to improve your coding skills.
   
As suggested by the others, it should be
#include <stdio.h>

int main()
{
  const char * name = "Daniel";
  printf("Hello my name is %s\n", name);
  return 0;
}
   
That needs to be a "char *".
C++
char * name = "Daniel";
   
v3
You must use "char Name[]" as array.

#include <stdio.h>
int main(){
char Name[] = "Daniel";
printf("Hello My Name Is %s",Name);
}
   
v2
Comments
Richard MacCutchan 8-Dec-19 9:41am
   
Look at the answers by CPallini and Rick York.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900