Skip to main content
Filter by
Sorted by
Tagged with
-3 votes
0 answers
150 views

I understand that std::cin/std::cout are generally slower than scanf/printf, and that's primarily due to synchronization with C’s standard streams. However, all explanations I saw just say that and ...
Ranko's user avatar
  • 145
1 vote
7 answers
307 views

I have a data file containing a number of 4 bit values in hexadecimal with a leading zero separated by commas.. 00,00,00,00,00,00,00,00,00,00,00,00,00,00, 00,04,00,00,00,00,00,00,00,00,00,00,00,00, 0a,...
Mike T.'s user avatar
  • 417
4 votes
4 answers
225 views

There is a code where I enter ABCDEFGH and press enter, and the final result is HGF. When I use debug mode to observe variables. When executing the first sentence input, x='A'. After the next step, x='...
Clara's user avatar
  • 141
5 votes
3 answers
290 views

I am trying to write a computer programme that will take two numbers from the user as inputs and will print the bigger number using bitwise operation. I want it to end the programme and return 1 if ...
uran42's user avatar
  • 469
5 votes
2 answers
446 views

I am currently trying to make a simple little program (BMI index calculator), since I have just started learning C. Currently using Eclipse. Here is my code: #include <stdio.h> int weight, ...
John.D's user avatar
  • 61
2 votes
1 answer
84 views

I'm making a program that reads multiple structs in and out of different files. For one of them, I have a format for reading from the file, and one for writing to it. #include <stdio.h> int ...
Alexandre Filho's user avatar
2 votes
1 answer
146 views

I'm a beginner programmer learning C as a hobby. I just learned about accepting user input using scanf() and thought it would be a fun learning experience to make a small "game" that runs in ...
gus's user avatar
  • 23
1 vote
2 answers
111 views

I want to write a computer programme that will do the following things : Ask for two integer inputs n and k from the user using scanf. If one of the scanfs don't return 1, it will print "Failed&...
uran42's user avatar
  • 469
1 vote
1 answer
74 views

I am planning to make a Linear Regression model using C. It takes a set of m points as input from stdin using scanf. The points are defined as a struct: typedef struct{ double x; double y; } ...
Nirav Pandey's user avatar
3 votes
2 answers
121 views

I was doing a CTF reversing challenge when I came across this C code in Ghidra: int main(void) { int iVar1; char input[32]; fwrite("Password: ",1,10,stdout); __isoc99_scanf("...
1zverg's user avatar
  • 875
1 vote
1 answer
144 views

I am trying out a program to generate a linked list, and to do it, I am asking for a Y/N character input from the user to generate a new node. However, the program just abruptly terminates after the ...
Rudro's user avatar
  • 11
1 vote
2 answers
120 views

was trying to write some c code to read a text file which contains some hex value in the follow format AA BB CC DD Containing 1 Byte of hex values per line in the file. the following is the code I ...
miner_kai's user avatar
1 vote
1 answer
187 views

I am a novice to programming, and I'm doing it for fun. I encountered a strange bug I do not understand while trying to parse simple user input. My problem is that when an invalid character is read (...
violetRM's user avatar
5 votes
4 answers
185 views

I'm learning C and trying to understand how scanf works. I can't understand some terms: the term "input item", "initial subsequence", "matching sequence". I am reading ...
Akramat's user avatar
  • 163
2 votes
3 answers
131 views

I'm using fscanf to parse a string, and I've been using it thusly: fscanf(file_in, "%i: %s%c%s", &current_id) == 4 Ignore the weirdness of the formatting(I know I could probably get away ...
GooseyLoosey's user avatar
0 votes
1 answer
149 views

#include <stdio.h> int main(void) { int total=0; int i, num; printf("Sum of 0 to num, enter num: "); scanf("%d", &num); for(i=0; i<=num; i++) ...
차원우's user avatar
3 votes
3 answers
131 views

#include <stdio.h> #include <stdlib.h> #define MAX_SIZE 100 // Maximum size of the arrays int main() { FILE *file; int array1[MAX_SIZE], array2[MAX_SIZE]; int i = 0, j = 0; ...
user1237538's user avatar
0 votes
2 answers
122 views

program 1: #include <stdio.h> #define MAXSTR 100 int main() { char ch; char str[MAXSTR]; char line[MAXSTR]; scanf("%c", &ch); // Just read character ...
Lavya's user avatar
  • 1,641
0 votes
1 answer
74 views

I am trying to parse this input file temperatures.txt, but currently I am having trouble with formatting the input correctly. I have tried many renditions so now I am looking for help. The issue I am ...
Henry Lj's user avatar
3 votes
1 answer
94 views

There is a difference in the scansets %1[x+-/] and %1[x/+-]. The first will also accept , and . but the second rejects those characters. #include <stdio.h> #include <stdlib.h> char ...
xing's user avatar
  • 2,528
0 votes
2 answers
107 views

I want to make a function that reads a value from the user with spaces, for example ("Noble Gas").I found a way that works if i run it alone but not in my function. The code lets me input ...
MrKotopoulos's user avatar
0 votes
1 answer
122 views

Is it important to add a white space before all format specifiers with scanf in c programming? scanf(" %d",&variable_name); scanf(" %c",&variable_name); And will it be ...
Devil's user avatar
  • 1
0 votes
3 answers
133 views

#include <stdio.h> #include <stdlib.h> int main(){ char name[100]; int age; printf("Enter you name:\n"); scanf("%s", name); printf("Enter you ...
cha's user avatar
  • 29
1 vote
1 answer
112 views

so i did try it with using a for loop but every single time my output skips the value of index 0 and i just dont understand why.... here is my code : // take char by char input and print it as string ...
Rudraksh_pd's user avatar
0 votes
2 answers
272 views

So I am new to coding and am teaching myself C. Today I was trying to write a simple program using scanf() but I'm not getting the output I expect. Whatever number I type it seems like scanf() either ...
truballin's user avatar
1 vote
2 answers
130 views

I am trying to post this to the C board. If I am in the wrong place, or this is not an appropriate question please let me know so can delete or move this. Thank you very much. I am learning C as my ...
simspawn's user avatar
  • 119
1 vote
0 answers
47 views

I am working on a program in C to parse data from a CSV file. The structure of my CSV file includes fields that may be empty, and I need to handle these cases properly. Here's an example of a CSV row: ...
DJABRI MAROUANE's user avatar
2 votes
1 answer
218 views

I am trying to use a negated scanset technique with scanf (I am not allowed to use anything else so no getchar()). But I have a small problem with it. When I use scanf(“%*[ \n]%*c”). If I enter an ...
ori's user avatar
  • 21
0 votes
1 answer
91 views

Please see the following piece of code in C printf ("\nEnter the lines (terminate each line with ENTER...\n\n"); for (i = 0; i < lines; i++) scanf (" %[^\n]", s[i]); I have ...
Vinayak Deshmukh's user avatar
-1 votes
4 answers
172 views

#include <stdio.h> int main() { int y = 0, w = 0; scanf("%d %5c", &y, &w); printf("%d,%c\n", y, w); return 0; } When i input 2000 12345, the output ...
kangaroo's user avatar
1 vote
2 answers
119 views

I have a .dad file with the content 1/2 I wish to read from the file and save the value 0.5 into a double using fscanf, but the method reads it as 1.000. To be completely clear, here is the code and ...
Sam's user avatar
  • 494
1 vote
0 answers
131 views

I'm trying to do parallel execution of several fscanf to read file faster I have 10 nums in a file 10-nums.txt 478 205 256 175 196 52 594 333 72 777 and have a simple code main.c #include <stdio.h&...
EzioMercer's user avatar
  • 2,149
2 votes
3 answers
106 views

#include <stdio.h> #include <ctype.h> void task(const char *file_name) { FILE *file = fopen("1.txt", "r"); if (file == NULL){ printf("Error ...
ppa's user avatar
  • 41
0 votes
3 answers
123 views

printf("Commands:\n"); printf(" add <word>: adds a new word to dictionary\n"); printf(" lookup <word>: searches for a word\n"); ...
Haze345's user avatar
-1 votes
1 answer
95 views

anytime i run this function in my program void treeInput(){ char temp; int x, tempRow, tempColm; while(x=0){ scanf(" %c ", &temp); if(temp == 'Q'){ ...
Sarah Madden's user avatar
3 votes
4 answers
188 views

I am trying to do a postfix evaluation using stack. The output is supposed to be in a format 2,3,4,+,-,# with # signifying the end of expression. The problem is negative numbers are allowed i.e 2,3,-...
Arka's user avatar
  • 33
0 votes
1 answer
113 views

For example: int number = scanf("%d", &number);
Kar Lee's user avatar
  • 31
0 votes
1 answer
105 views

I am writing code using Scanf and i want it to take in three different inputs at once perform some computations using those inputs and give me an output but it is not working as i expected . Firstly ...
Olayo Martin's user avatar
1 vote
3 answers
202 views

I must use scanf() to read each 2-digit hexadecimal value. Each 2-digit hexadecimal number will be separated by a single space and a ‘\n’ character (rather than a space after the number) will indicate ...
user27217858's user avatar
2 votes
1 answer
125 views

For some context, my game runs in the terminal and is like a command line type game. At the moment to process commands is does a strcmp() for every single command which isn't really pretty nor ...
some guy who likes C's user avatar
0 votes
0 answers
32 views

I am new to C language coding, I was trying to learn the various inputs that I can take from the user and display the same but I keep getting a blank in the place of the printf statement that takes ...
Saikat Das's user avatar
0 votes
2 answers
119 views

Have to take a input string of size 5. Also have to check for validity in some unrelated sense. If the input is not valid user is prompted to input again. Using the scanf("%4s", input); But ...
Syntax Error12's user avatar
0 votes
1 answer
105 views

I made a simple program for a class using c and printf would work just fine; however, when I added the Scanf function, nothing would work not even the printf lines. My teacher used the same code on VS ...
Cody T's user avatar
  • 11
0 votes
1 answer
101 views

It just gives me 2.5 as an answer whenever I input the num and I don't know why, so any help would be greatly appreciated! #include <stdio.h> double equ(double num); int main() { double ...
Nksho27's user avatar
0 votes
1 answer
72 views

I want to calculate average of the numbers entered by the user, where the user can enter as many numbers as he/she wants , i.e., the loop will stop only when the user wants. To stop the loop from user'...
S Das's user avatar
  • 111
1 vote
2 answers
138 views

The *scanf() family of functions return the number of "input items" (that is, conversion specifications) successfully matched and assigned: RETURN VALUE On success, these functions return ...
intelfx's user avatar
  • 2,975
0 votes
1 answer
124 views

#include <stdio.h> int main() { char a[12]; int b = scanf("%11s", a); if (b != 1) { return 1; }; if (printf("%s", a) > 11) { return 1; ...
user avatar
2 votes
1 answer
83 views

im working on a script which will read a string from the user and print it back, i wanted the script to read the input using scanf and print it back with printf. So far i tried following those forums: ...
Hrodebert's user avatar
0 votes
3 answers
107 views

Basically my input file is in the format: I 15 3 15 10 10 20 S -5 3 15 82 I -20 80 -4 10 S 4 -20 8 The number of ints in a row can vary, but there is always one char at the beginning of each ...
Neel Varma's user avatar
3 votes
2 answers
217 views

Why when I run this code: #include <stdio.h> int main () { int a, b; if (scanf("%d %d", &a, &b) == 2) printf("%d %d", a, b); else printf(...
Ilya's user avatar
  • 33

1
2 3 4 5
151