我键入以下代码以获取主目录。我后来对其进行了编辑,以包括所有代码:
#include <math.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <pwd.h>
#include <stdarg.h>
#include "anotherfile.h"
typedef unsigned int uint;
void Interval(void) {
static uint S = 0;
static uint C = 0;
static uint M = 0;
static uint D = 0;
usleep(10e5/0x20);
printf("%d\n", C);
printf("%d\n", S);
printf("%d\n", M);
if(C == 0x20) {
if(S == 59) {
S=0;
M++;
}else{S++;}
C=0;
}else{C++;}
Interval();
}
int main(int argc, const char *argv[]) {
char *HomeDir;
if((HomeDir = getenv("HOME")) == NULL) {
HomeDir = getpwuid(getuid())->pw_dir;
if(HomeDir == NULL) {
printf("Failed to get Home Directory\n");
}else{printf("Retry Home Directory Found\n");}
}else{printf("Success getting Home Directory\n");}
Interval();
return 0;
}
它给了我隐式声明警告。它说getenv
部分有些东西我该如何解决?