34 questions
1
vote
1
answer
83
views
Printf command stops working when DEBUG trap is active?
When I set a DEBUG trap in Bash like this:
set -o functrace
trap 'echo "# $BASH_COMMAND" >&2' DEBUG
Suddenly, this function stopped working:
getBase() {
local base="$1"
...
0
votes
0
answers
216
views
Sprintf function converting int to a single char instead of a string
I'm trying to convert the unsigned long integer converted_binary, which contains 10000000000 to a string, but sprintf converts it to a single character 1 instead.
I am able to know this through the ...
0
votes
1
answer
101
views
Trouble understanding statement order in Chisel
Here is a simple module containing a down counter:
import chisel3.util.{Valid, DeqIO}
class Input(WIDTH : Int) extends Bundle {
val x = UInt(WIDTH.W)
}
class Output(WIDTH : Int) extends Bundle {
...
1
vote
1
answer
134
views
C struct glitch? (I am new to programing in C)
I am learning how to create struct's and I am stuck on a program I made. Everything works fine until I try to input "2". When the program prints the symbol it's supposed to be "He" ...
0
votes
1
answer
73
views
Why removing a printf function messes up with my code? CS50 pset1 cash greedy challenge
I finished the challenge and my first C code worked apparently well, returning each time the correct minimum number of coins needed for change. Then when I tried to "clean it up" a bit and remove a ...
0
votes
1
answer
535
views
printf not print string after \n (Compiler GCC)
See my code
char t[]= "{\n abcdeffgjejgjergnjkengkknkn \n";
printf("%s",t);
char t1[]= "{ abcdeffgjejgjergnjkengkknkn \n aaffdefa";
printf("%s",t1);
Actual Output:
{
{ abcdeffgjejgjergnjkengkknkn
...
1
vote
3
answers
775
views
For loop with printf as arguments
I can't understand why the following code outputs 10.
What I understand is that !printf("0") means !0, which is TRUE. So why doesn't the code print "Sachin"
#include <stdio.h>
int main() {
...
-1
votes
1
answer
1k
views
Ignoring special characters while preserving formatting with MATLAB's fprintf function
I have a string array in a matlab script called "dataString" that was copied into MATLAB from an html document using fileread(). I then cut out the part I wanted and stored that in dataString.
TEXT =...
0
votes
2
answers
1k
views
printf crashes after successful printing
Language is C. I have an array of char* types (char *array[] / char** array) as function argument, and I want to print them all to separate lines like this:
while (*array) {
printf("%s\n", ...
2
votes
1
answer
8k
views
How to pass application printf messages to /var/log/messages
I want to pass application printf log messages to the /var/log/messages.
Because kernel debug messages can be visible to /var/log/messages.But i am not getting how to pass application printf log ...
-1
votes
1
answer
457
views
Undefined reference in Kdevelop
I have main.cpp, linking test function from io.c
#include <iostream>
#include "io.h"
int main(int argc, char **argv) {
test();
return 0;
}
io.c:
#include <stdio.h>
#include "io....
0
votes
1
answer
760
views
printf debugging to trace a function
I'm trying to port software to a microcontroller (so I can't step through the code with e.g. gdb) and it crashes unpleasantly.
To identify the reason for this, I want to insert a printf() before every ...
0
votes
1
answer
581
views
python - is there no better way to get the expression in a debug function
in c code I frequently use printf debugging macros like
#define DPRINT_INT(i) fprintf(stderr,"%s has the value %i at line %i", #i,i, __LINE__)
and then i can do things like
DPRINT_INT(height)
where ...
6
votes
2
answers
8k
views
Setting CFLAGS for pr_debug and printk
I am trying to understand a Linux kernel module and would like to see the output of pr_debug and printk. I am using GNU Make.
I understand that to get pr_debug messages, we have to use DDEBUG.
...
8
votes
11
answers
3k
views
Educational example to show that sometimes printf as debugging may hide a bug
I remember when I was in some course of C programming, a teacher once suggested that I use printf to watch the execution of a program that I was trying to debug. This program had a segmentation fault ...
-1
votes
2
answers
138
views
Why would a log statement change the output of a program?
I was once asked during an interview the following question, and I've still never been quite clear on the answer. I was wondering if anyone knew where I could learn more, googling hasn't been much ...
330
votes
11
answers
249k
views
How do I dump an object's fields to the console?
When I'm running a simple Ruby script, what's the easiest way to dump an object's fields to the console?
I'm looking for something similar to PHP's print_r() that will work with arrays as well.