我的C程序返回错误?警告:初始化从指针生成整数而没有强制转换[-wint-conversion] |?救命! [英] My C program returns error? Warning: initialization makes integer from pointer without a cast [-wint-conversion]|? help!

查看:1863
本文介绍了我的C程序返回错误?警告:初始化从指针生成整数而没有强制转换[-wint-conversion] |?救命!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码

  #include   < span class =code-keyword><   stdio.h  >  
int main(){
char 名称= Daniel;
printf( Hello My Name is%s,Name);
}





这是我的错误:

警告:初始化使整数来自没有演员阵容的指针[-Wint-conversion] |



我尝试了什么:



我已经尝试过stackoverflow,我也看了遍布谷歌但无法找到awnser。我也试过quora

解决方案

Rick是正确的但您需要添加

 返回  0 ; 

在主要功能结束时!!!



访问一些教程,如学习C 提高您的编码技能。


正如其他人所建议的那样,它应该是

 #include< stdio .H> 

int main()
{
const char * name =Daniel;
printf(Hello我的名字是%s \ n,姓名);
返回0;
}


需要是char *。

  char  * name =   Daniel; 


This is my code

#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

解决方案

Rick is right but you need to add a

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 *".

char * name = "Daniel";


这篇关于我的C程序返回错误?警告:初始化从指针生成整数而没有强制转换[-wint-conversion] |?救命!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆