2012/7/19-11/7 [Computer/SW/Languages/C_Cplusplus] UID:54439 Activity:nil | 7/19 In C or C++, how do I write the code of a function with variable
number of parameters in order to pass the variable parameters to
another function that also has variable number of parameters? Thanks.
\_ The usual way (works on gcc 3.0+, Visual Studio 2005+):
#define foo(fmt, ...) printf(fmt, ##__VA_ARGS__)
The cool new way (works on gcc 4.3+):
...
|
2012/7/23-29 [Computer/SW/Languages] UID:54443 Activity:nil | 7/23 Hey mconst, check this out:
int main()
{
int i_value = 16777217;
float f_value = 16777217.0;
printf("The integer is: %d\n", i_value);
...
|
2011/2/5-19 [Computer/SW/Languages/C_Cplusplus] UID:54027 Activity:nil | 2/4 random C programming/linker fu question. If I have
int main() { printf("%s is at this adddr %p\n", "strlen", strlen); }
and soda's /proc/sys/kernel/randomize_va_space is 2 (eg; on)
why is strlen (or any other libc fn) at the same address every time?
\_ I don't pretend to actually know the right answer to this, but
could it have something to do with shared libraries?
...
|
2009/4/6-13 [Computer/SW/Languages/C_Cplusplus] UID:52806 Activity:moderate | 4/6 In C++, if there are several instances of an object, and for
debugging purpose I want to see which instance of an object it is, I
can do 'printf("%p", pObj);' to print out the address of the object.
Is there any way to do something similar in C#? Thanks.
\_ CLR objects can get shuffled around in memory nondeterministically.
Using the address or something like that won't work for identifying
...
|
2006/7/13-18 [Computer/SW/Languages/C_Cplusplus] UID:43667 Activity:nil | 7/13 How do you get milliseconds in C? I want to do something like:
t1=sec;
long_operation_that_needs_to_be_benchmarked();
t2=sec;
printf("This operation took %f seconds", (t2-t1));
\_ You could try using clock() and CLOCKS_PER_SEC.
...
|
2005/6/21-23 [Computer/SW/Languages/Perl] UID:38230 Activity:high | 6/21 My math and/or perl fu is weak. Is there a way to get integer
multiplication in Perl the way it's done in C? i.e. limiting
to 32 bits. Like 1588635697 * 1117695901 = 1166976269 in C.
\_ Can't you just multiply and then mask all but the last 32 bits?
\_ I don't think so; that's not the same as mult overflow.
> perl -e 'print (1588635697 * 1117695901)'
...
|
2005/2/17 [Computer/SW/Languages/Perl] UID:36220 Activity:high | 2/17 This *has* to exist: I'm working w/ a text file that uses ascii #2
for record separators and ascii #1 for field separators. Is there
a utility that will print out these ascii values for me, so I can
(for example) use them with command line awk and perl scripts? Ex:
fs=`atoi 1`
perl -pi e's/(.*)$fs(.*)/$1$fsfoobar/g' myfile.txt
...
|
2004/10/1-2 [Computer/SW/Unix] UID:33873 Activity:moderate | 10/1 If i want to awk '{print $2+}' is there a way to do that without
looping, or am i being TOO lazy?
\_ perl
\_ probably. what are you trying to do in not-awk-speak?
\- you can use this loop. there might be a range operator
in some versions of awk, but not in generic awk. --psb
...
|
2004/9/27 [Computer/SW/Languages/C_Cplusplus] UID:33781 Activity:high | 9/27 How are functions like C's printf made? It can take 1-N arguments and
the 2-N arguments can be of almost any type. How do you write a
function like that? Surely printf wouldn't work with 500 arguments?
\_ probably would, depends on how much stack you have. See <stdarg.h>
\_ man stdarg
\_ Has to do with the ... function argument notation. Check your
...
|
2004/9/20-21 [Computer/SW/Languages/C_Cplusplus, Uncategorized/German] UID:33644 Activity:moderate | 9/20 C question. If I have
#define NAME FOO
is there any way to use NAME to create a string "FOO"? Thanks.
\_ Do you mean #define NAME "FOO" ? Or do you want to declare a
variable? Can you show NAME used in a sample line of code?
\_ What I want is something like, say,
...
|
2004/5/13-14 [Computer/SW/Languages/C_Cplusplus] UID:30202 Activity:very high | 5/12 nCircle is looking for an experienced software engineer. See
/csua/pub/jobs/nCircle.sweng
\_ so I have been doing java, and I still believe I'm an expert
c/c++ programmer. However, if you ask me what are
the printf format parameters, I doubt I could tell you much
other than %s. So I can definitely get a book on c/c++ and
...
|
|