I usually stick to c# or java but i need something a little more low level so I'm trying c. I was wondering, how do you use environment variables like %windir%. I'm using tcc.
5 replies to this topic
#1
Posted 23 January 2011 - 12:34 PM
|
|
|
#2
Posted 23 January 2011 - 12:55 PM
#3
Posted 23 January 2011 - 02:08 PM
this is the code
and this is the output
any ideas?
#include <c:\windows\tcc\include\stdio.h>
#include <c:\windows\tcc\include\stdlib.h>
void main()
{
printf(getenv("CDir")+"\n");
}
and this is the output
test.c:6: can not use pointers here
any ideas?
#4
Posted 23 January 2011 - 02:11 PM
oh, and CDir = "c:\windows\tcc"
#5
Posted 23 January 2011 - 02:39 PM
That is a strange error message, though probably not any stranger than one GCC would give you.
Anywho, you can't concatenate C strings by using the + operator. You need to use a special function. However, since your using printf you can simply say something like this.
Anywho, you can't concatenate C strings by using the + operator. You need to use a special function. However, since your using printf you can simply say something like this.
printf("%s\n", getenv("CDir"));Search cplusplus.com (don't be fooled by the name, it documents a lot of C functions as well since C is kind of a subset of C++) for printf to check out the full usage.
#6
Posted 23 January 2011 - 02:56 PM
thanks.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









