XP中编译时在Win7中出现getusername错误 [英] getusername error in win7 as comlication complied in XP

查看:313
本文介绍了XP中编译时在Win7中出现getusername错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在XP中编译该应用程序,并且将其安装在win7的某些计算机上,getusername函数无法正常工作.

complie the application in XP, and  install it in win7, in some computer ,the getusername function doesm't work well.

如果用户名是"jason", 在win7的某些计算机上,它将用户名显示为"son",第一个和第二个ch丢失了.

if the user name is 'jason',  in some computer of win7, it shows the username as 'son', the first and the second ch are lost.

不是每台计算机都会出现此问题,而在WINXP中是win7的某些计算机,就没有此问题.

the problem doesn't happen in every computer but some computer of win7,in WINXP,it does not have this problem.

 

谢谢和最好的朋友!

推荐答案

尝试此功能.

#include < stdio.h>
#include < stdlib.h>

int {
   字符   p  =  getenv  &"; UserName"  ) ;
  
  如果 p !=  NULL     printf  ( 当前名称是: %s" ,&p

) ;
    
  返回 ;
}

#include <stdio.h>
#include <stdlib.h>

int main ()
{
  char *p;

  p = getenv "UserName" );
  
  if (p != NULL)
    printf ("The current name is: %s", p);
    
  return 0;
}

GetEnv()函数根据您的输入查找本地环境设置.


这篇关于XP中编译时在Win7中出现getusername错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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