Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
1 vote
2 answers
105 views

Remove trailing whitespaces within [] with sscanf

I need to parse lines returned by utmpdump /var/log/wtmp. They are in this format: [8] [13420] [ ] [ ] [pts/3 ] [ ] [0.0.0.0 ] [2024-07-22T11:18:29,836564+00:...
Łukasz Przeniosło's user avatar
2 votes
1 answer
72 views

String allocated on the heap is corrupted when being accessed outside of the function C

I was trying to write some code in C to replace a substring in a given string following this tutorial. I managed to get it working, however one of the problems with the function is that it will result ...
Ali Awan's user avatar
  • 322
0 votes
1 answer
64 views

Why is there random stuff in my string when printing its bytes?

I'm trying to see how format string bug works and tried to explore it by myself. This is a simple program: #include"stdio.h" #include"string.h" struct mystruct{ char buf[32]; ...
Mateusz's user avatar
  • 11
-3 votes
1 answer
88 views

How do you use the "string" function is c [closed]

I was watching this CS50 course on computer science and it asked me to add the CS50.h header file but it wasn't available in my vs code as it wasn't cloud based like the cs50 one was I wasn't really ...
ScrawnyBrat's user avatar
0 votes
0 answers
42 views

Why doesn't function parameter give seg fault error? [duplicate]

A character array declared as char str[] = "Gear"; can be modified but char* str = "Gear"; is a string literal that cannot be modified and gives seg fault error if we try to change ...
Vishal 's user avatar
0 votes
0 answers
58 views

In C, There is no buffer overflow in strings [duplicate]

Whenever we store data more than the memory allocated to variable we got some unexpected results.But I declare a character array (name) with size 5 and get value from the user (greater than 5 ...
Allwin_6's user avatar
0 votes
0 answers
29 views

unable to take input of strings from user [duplicate]

I have to make an array of structure for cricketers presenting their name, age etc. and take input of each value from user . I am trying to get value of name from the user but my code editor keeps on ...
Harshit Gupta 's user avatar
0 votes
3 answers
87 views

Error in assigning values to memory location with for loop [duplicate]

I have just entered the world of C programming, and I'm currently learning how to use malloc & free. I've written a short excercise code to printf the string entered with scanf, and I am having ...
Woodrow's user avatar
  • 27
0 votes
3 answers
134 views

Is There a Better Way to Stringify Error Codes?

This is more of an aesthetic question than a purely functional one, but I want to know if there's any answer. See, I'm programming an error reporter for a project I've recently begun working on, and ...
Zenais's user avatar
  • 108
3 votes
2 answers
70 views

fwscanf failing to read UTF-8 CSV file correctly in C

This program can only use libraries of the C standard. I'm trying to read a UTF-8 encoded CSV file in C using fwscanf, but I'm encountering issues with the reading process. The file contains rows with ...
iPc's user avatar
  • 53
1 vote
0 answers
63 views

Handling Large Text Files with Pipes in C: Minimizing and Debugging a Word Frequency Counter

This program is a minimized version of a larger project that processes text files to generate CSV output with word frequencies. The full version works well for small to medium-sized files but ...
iPc's user avatar
  • 53
-1 votes
3 answers
110 views

C segfault question: if one of two inputs is null, return the other

I have a function that takes two strings and returns another string (if you must know, its my implementation of strjoin). Now, I want to make it so that if one of the input strings is NULL, it will ...
Cab the Kid's user avatar
0 votes
3 answers
95 views

Properties of strings

#include <stdio.h> int main() { char str[2]; printf("Enter anything "); scanf("%s",str); printf("%s",str); } What will become the output ...
Shamil Roshan.N's user avatar
0 votes
0 answers
46 views

Why does the commented C code skip user input when called from another function? [duplicate]

The function with the problem void login_starts() { while (TRUE) { memset(username, 0, USERNAME_MAX_SIZE*sizeof(char)); HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); ...
Infinite Intuitions's user avatar
0 votes
1 answer
67 views

How not [?] to convert an enumerator into its corresponding string literal

Since I can't ask the author, I ask the community for suggestions: Why would you want to convert an enumerator into its corresponding string literal like done by the following example? char* ...
Björn G. Kulms's user avatar

15 30 50 per page
1
2 3 4 5
951