请问这样找SYStem目录错误在哪里?
#include <stdio.h>
#include <windows.h>
int main()
{
char *GetWinSysPath()
{
#define MAX_PATH_LEN 256
AnsiString lpBuffer;
lpBuffer.SetLength(MAX_PATH_LEN);
GetSystemDirectory(lpBuffer.c_str(),MAX_PATH_LEN);
int pos=lpBuffer.Pos("System");
AnsiString path=lpBuffer.SubString(1,pos-1);
return path.c_str();
}
}
________________________________________________________
返回的错误是
C:\Documents and Settings\CYC\桌面\VC程序\Project\text.cpp In function `int main()':
5 C:\Documents and Settings\CYC\桌面\VC程序\Project\text.cpp expected primary-expression before "char"
5 C:\Documents and Settings\CYC\桌面\VC程序\Project\text.cpp expected `;' before "char"
请问问题根源在哪里呢?
[解决办法]
汗,函数能嵌套吗??
[解决办法]
#include <stdio.h >
#include <windows.h >
char *GetWinSysPath()
{
#define MAX_PATH_LEN 256
AnsiString lpBuffer;
lpBuffer.SetLength(MAX_PATH_LEN);
GetSystemDirectory(lpBuffer.c_str(),MAX_PATH_LEN);
int pos=lpBuffer.Pos("System");
AnsiString path=lpBuffer.SubString(1,pos-1);
return path.c_str();
}
int main()
{
GetWinSysPath();
return 0;
}