34 questions
0
votes
1
answer
72
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
76
views
Why I can't use printf() with variable 'i' as argument
`
void DisplayFood(int*NumOfFood,int*Rno,char *Names[],int*Price,int*Quantity,char*mfg[],char*exp[]) {
int i =0;
for(i=0;i<*NumOfFood;i++) {
printf("\n%-20d",Rno[i]);
...
0
votes
0
answers
215
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 ...
1
vote
2
answers
289
views
Inject string to const char* message in custom logger printf-style function
I have a debugger class which implements a printf() c style method.
It looks like this:
#define NO_DEBUG 0
#define NO_PREFIX 1
#define DEBUG_INFO 2
#define DEBUG_SUCCESS 3
#define DEBUG_WARN 4
#define ...
0
votes
1
answer
97
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 {
...
-2
votes
1
answer
139
views
how can we see the .exe printf message [closed]
I have an question about the .exe log. I am using raspberry pi 4 module with Debian OS where I am running my c-program from the .service base auto-start .exe process. Which is running well So whenever ...
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
0
answers
83
views
Function doesn't return expected value and printf doesn't return any value
Hi I am new to C but not to programming(Only have experience in high-level languages like Python and JS).
In my CS assignment I have to implement a function that decodes an encrypted string.(The ...
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
1k
views
printf for a C (not C++) program while using Qt Creator (not using any kinf of Qt framework)
Please note this is not C++ code and I'm not developing a Qt app.
I mostly develop embedded code and someone has knocked up a neat LCD emulator so we can write quite a lot of the code independent of ...
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
...
0
votes
3
answers
2k
views
Variable declaration inside curly braces
Why does the following code produce an error? I don't understand why the curly braces are making a difference.
#include<stdio.h>
int main(void)
{
{
int a=3;
}
{
...
1
vote
3
answers
769
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() {
...
0
votes
4
answers
88
views
Program compiles but then gives error Exception in thread "main" java.util.IllegalFormatConversionException: d != java.lang.Double?
My program is supposed to print out a table like this:
Time Fraction Since Midnight
12:00 AM 0.0000
1:00 AM 0.0417
2:00 AM 0.0833
3:00 AM 0....
-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 =...