No edit summary |
(Change <tt> to <code>, perhaps also minor tweak.) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{Dodgy|This is only useful in junk programs with simple functions. Also, it shows the return value, not "what it's printing out".}} |
||
− | {{review}} |
||
+ | {{TipImported |
||
− | {{Tip |
||
|id=1436 |
|id=1436 |
||
+ | |previous=1435 |
||
− | |title=wrap function calls in a print statement |
||
+ | |next=1437 |
||
− | |created= |
+ | |created=2006 |
|complexity=advanced |
|complexity=advanced |
||
|author=Peter Jenkins |
|author=Peter Jenkins |
||
|version=5.7 |
|version=5.7 |
||
|rating=68/24 |
|rating=68/24 |
||
+ | |category1= |
||
− | |text= |
||
+ | |category2= |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
+ | <pre> |
||
⚫ | |||
+ | </pre> |
||
⚫ | |||
⚫ | |||
⚫ | kind of a pain to type often. i also try to make it so the cursor ends up over the s so that you can replace it with d, etc for printing things other than strings. again, this works if you type in the commands as they are depicted, but not with the let statement. if you want to do it by hand, do something like qt (to assign it to "t"). then type what's in between the quotes, starting with 0. |
||
+ | <pre> |
||
⚫ | |||
+ | </pre> |
||
⚫ | |||
⚫ | |||
+ | You should use a debugger for this sort of operation. |
||
− | |||
− | |||
⚫ | |||
− | |||
− | |||
− | |||
⚫ | kind of a pain to type often. i also try to make it so the cursor ends up over the s so that you can replace it with d, etc for printing things other than strings. again, this works if you type in the commands as they are depicted, but not with the let statement. if you want to do it by hand, do something like qt (to assign it to "t"). then type what's in between the quotes, starting with 0. |
||
− | |||
− | |||
− | |||
− | |||
− | |||
⚫ | |||
− | |||
− | |||
− | |||
− | |||
⚫ | |||
− | |||
⚫ | |||
− | An alternative would be to become a real programmer instead of a code-monkey and learn how to use a debugger; that's exactly the use-case of debuggers. But of course, the so called "programmers" or "developers" of today don't need the help of such arcane tools because they are agile and whatnot. |
||
− | |||
− | '''Anonymous''' |
||
− | , December 9, 2006 2:29 |
||
---- |
---- |
||
⚫ | |||
− | I know how to use a debugger, thank you. Sometimes a debugger is more overhead than I want to deal with. |
||
+ | <pre> |
||
− | |||
⚫ | |||
− | Pete Jenkins |
||
⚫ | |||
− | , December 10, 2006 10:58 |
||
⚫ | |||
− | ---- |
||
+ | </pre> |
||
⚫ | |||
− | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | |||
⚫ | |||
− | |||
⚫ | |||
⚫ | |||
⚫ | |||
+ | <pre> |
||
⚫ | |||
+ | </pre> |
||
⚫ | |||
⚫ | |||
+ | <pre> |
||
⚫ | |||
+ | </pre> |
||
− | to remove all these |
+ | to remove all these printf when make release version. |
− | huangchao--AT--hotmail.com |
||
− | , January 23, 2007 0:41 |
||
---- |
---- |
||
− | <!-- parsed by vimtips.py in 0.831821 seconds--> |
Latest revision as of 06:25, 13 July 2012
created 2006 · complexity advanced · author Peter Jenkins · version 5.7
warning: i couldn't get this to work except by entering the commands, maybe there is a way to get the let statement to work but for me it has problems with the quotes. I couldn't figure out a way to properly escape them.
have you ever had a function in C: doSomething(a, b, c); and you want to see what it's printing out? this wraps that function so the output looks like this:
doSomething(a,b,c): 37
c for it looks like printf("doSomething(a,b,c): \"%s\"\n", doSomething(a,b,c));
kind of a pain to type often. i also try to make it so the cursor ends up over the s so that you can replace it with d, etc for printing things other than strings. again, this works if you type in the commands as they are depicted, but not with the let statement. if you want to do it by hand, do something like qt (to assign it to "t"). then type what's in between the quotes, starting with 0.
:let @a = "0f(byt;iprintf("^[pa: "~@kb\"%s\"\n", ^[$i)^[?%^Ml^]"
Comments[]
You should use a debugger for this sort of operation.
In fact, you can define
#define hcffl printf("\n= [ %s : %s : %d ] =", \ __FILE__,__FUNCTION__,__LINE__ \ ); fflush(stdout);
then, add
hcffl;
every where you need, and
#define hcffl ;
to remove all these printf when make release version.