Reputation: 265
I need to get the path of %APPDATA% in my c program, to save a file in
%APPDATA%\myprogram\
How can I do that ?
Upvotes: 0
Views: 295
Reputation: 3631
You should be able to get that information through getenv
, here is an example.
#include<stdio.h>
#include<stdlib.h>
int main ()
{
char * app_data;
app_data= getenv ("APPDATA");
if (app_data!=NULL)
printf ("The appdata path is: %s",app_data);
return 0;
}
Upvotes: 5