how can I put a breakpoint on “something is printed to the terminal” in gdb?

Use a conditional breakpoint that checks the first parameter. On 64-bit x86 systems the condition would be: (gdb) b write if 1==$rdi On 32-bit systems, it is more complex because the parameter is on the stack, meaning that you need to cast $esp to an int * and index the fd parameter. The stack at … Read more

Printing chars and their ASCII-code in C

This prints out all ASCII values: int main() { int i; i=0; do { printf(“%d %c \n”,i,i); i++; } while(i<=255); return 0; } and this prints out the ASCII value for a given character: int main() { int e; char ch; clrscr(); printf(“\n Enter a character : “); scanf(“%c”,&ch); e=ch; printf(“\n The ASCII value of … Read more

Should I use %i or %d to print an integer in C using printf()?

They are completely equivalent when used with printf(). Personally, I prefer %d. It’s used more often (should I say “it’s the idiomatic conversion specifier for int“?). (One difference between %i and %d is that when used with scanf(), then %d always expects a decimal integer, whereas %i recognizes the 0 and 0x prefixes as octal … Read more

How to correctly printf strings and characters with %s and %c

If you try this: #include<stdio.h> void main() { char name[]=”siva”; printf(“name = %p\n”, name); printf(“&name[0] = %p\n”, &name[0]); printf(“name printed as %%s is %s\n”,name); printf(“*name = %c\n”,*name); printf(“name[0] = %c\n”, name[0]); } Output is: name = 0xbff5391b &name[0] = 0xbff5391b name printed as %s is siva *name = s name[0] = s So ‘name’ is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)