Skip to main content
Filter by
Sorted by
Tagged with
2 votes
1 answer
143 views

I am encountering a problem inside a while loop that is embedded in a for loop iterating through a struct of arrays. The issues I am coming across is before the array iterates again, I want to have ...
Zachary Vandermude's user avatar
3 votes
2 answers
273 views

So, I am learning C language and was trying to make a function that returns the length of a string. In the if statement I mistakenly used "" instead of ''. So, instead of comparing to char '\...
Schrey's user avatar
  • 69
2 votes
2 answers
133 views

My goal is to recreate the strcat() function without libraries: #include <stdio.h> char *ft_strcat(char *dest, char *src) { int i; int j; i = 0; j = 0; while (dest[i] !...
superlemon's user avatar
1 vote
3 answers
150 views

I know beginner level C++. In C++ when I want to, for example. input the user's name, all I need to dos is: getline(cin,str); but I am trying to learn C.( I want to play with kernels and embedded ...
Zulqarnain Bin Asif's user avatar
3 votes
2 answers
166 views

Is it safe to call free in the example below: size_t len = 10; char* buffer = static_cast<char*>(malloc(len)); std::string_view sview(buffer, len); free(sview.data()) Why do I need this? I have ...
Njrslv-yndx-cloud's user avatar
0 votes
3 answers
206 views

I have a question related to null operation in C. From my understanding and the thing i read here, a null operation or differently called a null byte, is used to tell the compilers the end of the ...
iii's user avatar
  • 107
0 votes
0 answers
45 views

I need help looking for the source of an error that's plaguing me in my coding assignment (I'm doing the class online over the summer.). The professor is tasking the class with several cstring ...
Sparky's user avatar
  • 1
0 votes
3 answers
147 views

bool isSubsequence(char* s, char* t) { int len = 0; bool res = false; int k = 0; len = strlen(t); char str[len+1]; uint64_t z; for (uint64_t i = 0; i < pow(2, len)...
pranjal bankar's user avatar
2 votes
3 answers
163 views

I have a function called escape that copies over a character array into a new one while replacing the \t and \n characters with raw characters \t and \n i.e single character '\n' becomes 2 characters '...
saberton's user avatar
4 votes
2 answers
132 views

My problem is that I have a string which is colored gray, the string is almost 1000 characters long. 2 of them must be in another color (red), but I don’t know how to change the color in the string. ...
Simon Rogl's user avatar
3 votes
3 answers
173 views

recently just practiced the problem 67 in Leetcode This problem is like you would be given two binary string, and you have to calculate the sum of these two binary string and return the result.For ...
Onion_in_1945's user avatar
10 votes
2 answers
1k views

Is there any situation where the literal const char*s "" and "\0" differ, or are they identical? Edit: As requested that an edit should be added, the answer to this question was ...
asimes's user avatar
  • 6,202
-1 votes
1 answer
181 views

I am learning C++. I have a code which is working, but now I am wondering if it can be optimized in terms of memory usage? I need to get and keep a few strings in a character array, but the number of ...
and his dog's user avatar
4 votes
3 answers
462 views

From what I understand it is very rare for UTF-8 strings to have embedded NULLs, however there is the case that a person can put a NULL into a Unicode string explicitly with "X\0Y" or ...
Tyler Durden's user avatar
  • 11.6k
3 votes
1 answer
291 views

The following code produces a warning in Swift6: 'init(cString:)' is deprecated: Use String(decoding: array, as: UTF8.self) instead, after truncating the null termination. var size = 0 ...
Chris's user avatar
  • 1,487
3 votes
4 answers
190 views

I'm trying to make a program that deletes extra white spaces from a string. It should keep one space but delete any extra. I wrote this code, which works up until the point I have to change the passed ...
user1497350's user avatar
1 vote
2 answers
66 views

Hi i'm trying to write a recursive function to extract each line of a string. I don't know why it doesn't work i spent 2 hours trying to find the issue. #include <string.h> #include <stdlib.h&...
Yuki's user avatar
  • 93
1 vote
2 answers
105 views

I am a beginner in C programming, and this is a string matching code I wrote. It aims to find the positions where the substring t appears in the string s and print them. The use of pointers is ...
Elliott T's user avatar
1 vote
3 answers
94 views

I have an assignment to write a function that takes two C-string parameters and appends the second to the first just like the strcat function but without using said function. Then, write a main driver ...
Marie B.'s user avatar
0 votes
1 answer
57 views

I am new to C++ and I do not understand why the code doesn't continute tokenizing the text array, and instead raises the error. I suspect that the problme might be because of passing the token ptr mid-...
Astor's user avatar
  • 3
0 votes
0 answers
32 views

Despite 5 years of development with ESP8266 (mini D1) I'l still confused: My IDE version is 1.8.19 My sketch is 3300 lines but I made a test case: This is the sketch: // Globals int i=1; void setup() ...
DMike92's user avatar
  • 23
4 votes
2 answers
223 views

This is fgets()'s official prototype: char *fgets(char *str, int n, FILE *stream); Why specify the size (n) ? Is it to prevent buffer overflow of some sort? Or is it just a design flaw? I would think ...
Cccc's user avatar
  • 93
1 vote
3 answers
153 views

For an assignment in my college data structures class, we have to define functions for a palindrome class that takes a word, checks if it is a palindrome, stores it as half the word, and can access ...
Leaf Man's user avatar
1 vote
1 answer
87 views

I ask for your help. I need to compare an array of tokens with a char using the if statement. But in the array I also have a string, the code is this: char bho(char** Token){ char* token = (char*)...
Bho's user avatar
  • 11
2 votes
3 answers
217 views

Just so I can confirm if what I think is going on is really going on. The following code prints out 25 when I give it the (26 letter) alphabet as an input, is it because fgets always automatically ...
Guilherme Cintra's user avatar
0 votes
0 answers
616 views

In this post, How you convert a std::string_view to a const char*?, the question was raised how to convert std::string_view into char* and the answer is basically: make a temporary string from the ...
igel's user avatar
  • 556
0 votes
1 answer
113 views

I've been trying to make a function in C that takes a string as the input and then prints out a version of that string that only contains alpha characters. #include <string.h> #include <ctype....
Lushana Elie's user avatar
0 votes
2 answers
88 views

I wrote the code below to try the strstr() function to search for a name in a list, but it is not finding it. Can someone please explain why this code fails to find the name I am trying to look for? #...
Siham Mohammad 's user avatar
1 vote
1 answer
88 views

I'm learning C using the book C Programming: A Modern Approach and I have some doubts about the use of pointers and referencing an out-of-scope variables. I've put together three examples to ...
videbar's user avatar
  • 33
1 vote
3 answers
121 views

Does s conversion specifier specify direction / order in which characters are written? N3220 working draft, 7.23.6p8 (emphasis added): s If no l length modifier is present, the argument shall be a ...
pmor's user avatar
  • 6,757
-1 votes
2 answers
92 views

The program is expected to sort and display a list of words from a array whose elements are pointers to char. I use malloc to alocate space to each element and use a read_line function to store in the ...
Pepe Cuesta's user avatar
1 vote
2 answers
8k views

I am a beginner to programming and today I was trying to swap two strings with somewhat of a raw , brute force logic . But I stumbled upon this behaviour : My code : #include <stdio.h> #include ...
M.B.'s user avatar
  • 279
0 votes
0 answers
138 views

// this is the old MFC CString (not actually dependant on CObject) vs the new ATL version that is implemented as a template char array[] = { 0x45, 0x46, 0x0, 0x45 }; CString a(array,sizeof array); ...
BobC's user avatar
  • 1
1 vote
1 answer
149 views

again. I've written a code on finding all possible combinations on a word and my code works but very limited times (i.e) it prints the string with "a" being only swapped (my I/P is abcd) but ...
user avatar
2 votes
4 answers
123 views

Task Convert number to Chinese Pinyin. Minus sign is equal to "fu". key-value # num: pinyin 0: ling 1: yi 2: er 3: san 4: si 5: wu 6: liu 7: qi 8: ba 9: jiu Code #include <stdio.h> ...
mamaruo's user avatar
  • 23
0 votes
1 answer
66 views

I would like to create a radix LSD to sort strings. I tried to adapt to a count[27] instead of count[256], because the exercise requires it. I must use A[I][d] - 'a' + 1 for [a-z] and 0 for spaces, ...
megarubber's user avatar
0 votes
1 answer
115 views

Here's function code: void TrimRight(char* s) { if(!*s) return; char* end = 0; for(char c; c = *s; s++) { if(c == ' ') { if(end == 0) end = s; } else end = 0; } ...
Gauliux's user avatar
1 vote
1 answer
176 views

I'm implementing a ziglang function to generate a ulid. So far it works when called via a main function. However, when using it with Bun's FFI it fails. (console.log) is an empty string. Zig const std ...
Mnengwa's user avatar
  • 327
0 votes
1 answer
76 views

important: I don't have a deep understanding of malloc so try to put things as simple as possible Greetings, I want to create a dynamic array of strings (using malloc) and then print those strings out ...
Dark Dev's user avatar
1 vote
1 answer
106 views

I stumbled on this class when browsing the internet this morning: CStrBufT. I understand that it is meant to be used instead of: CString::GetBuffer CString::GetBufferSetLength CString::ReleaseBuffer ...
Andrew Truckle's user avatar
1 vote
1 answer
126 views

So I am solving the "Longest Common Prefix" problem on Leetcode in C and have almost got it working. My Code: char * longestCommonPrefix(char ** strs, int strsSize){ int minlen = ...
Confused Coder's user avatar
0 votes
1 answer
61 views

I want to tokenize a provided input string using strtok(). In the first step, I want to tokenize the given string by "|" symbol. Then, I tokenize each substring by ";". Finally, I ...
Devon's user avatar
  • 1
1 vote
2 answers
457 views

I am trying to loop through an array that contains a string with is several words separated by spaces. Ultimately I want to make each word within the string a new variable so I can compare it to other ...
Archie H's user avatar
1 vote
1 answer
116 views

I have a word count program in C that excludes special characters and number digits: int main(){ char str[100]; int i, j = 0; int len; char choice; do { printf("...
Roshina De Jesus's user avatar
0 votes
1 answer
59 views

I just started learning C and i'm trying to write a program that inverts the string so that furthermore i can check if the string is a palindrome. I did it by adding a for loop limited by the size of ...
raspiestchip's user avatar
0 votes
0 answers
321 views

I'm programming an STM32 microcontroller. In the code I'm just calling sprintf the way I did before and it worked then, but now it just freezes the entire program. What's the problem here? char str[...
epicMan123's user avatar
2 votes
3 answers
307 views

I've written this minimal reproducible example to calculate the Desktop folder on Windows "the hard way" (using SHGetKnownFolderPath), but I seem to end up with a Success error code while ...
JamesTheAwesomeDude's user avatar
0 votes
0 answers
36 views

I am re-creating the string class in C++. I developed both the constructor and the copy constructor as well as an operator+ method to concatenate two strings. The issue I am facing is that the copy ...
Mohamed Mahdi's user avatar
1 vote
3 answers
465 views

I tried to make my own strdup function to practice my C skills, but I'm not sure if it's legal or not. the function is down below: char* strdup(char* str) { char* dup_str; int len; for (...
Parker Mason's user avatar
1 vote
4 answers
229 views

I have a function that converts the content of strings from hexadecimal symbols to binary symbols. In my simple example I have used only two hex symbols a and b, and the same string is converted two ...
Eddy Sorngard's user avatar

1
2 3 4 5
66