Questions tagged [c-strings]
A string in the programming language C is represented as a sequence of characters followed by a null terminator (represented as \0).
c-strings
2,777
questions
0
votes
1
answer
93
views
Adding elements into a char array
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....
0
votes
2
answers
59
views
C++ logical error: strstr function not finding an available entry
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?
#...
1
vote
1
answer
77
views
C pointers: Function returns a pointer defined in its body [duplicate]
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
...
1
vote
3
answers
93
views
Does s conversion specifier specify direction / order in which characters are written?
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 ...
-1
votes
2
answers
77
views
char *array[200] sorting program doesn't read words
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 ...
1
vote
2
answers
8k
views
Unexpected behaviour while swapping strings in C
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 ...
0
votes
0
answers
100
views
Microsoft's newer (templated) CString does not handle null characters the way it did before
// 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);
...
1
vote
1
answer
97
views
Finding possible permutations of a word
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 ...
2
votes
4
answers
108
views
Number index to array element
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>
...
0
votes
1
answer
50
views
LSD Radix for a fixed count array
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, ...
0
votes
1
answer
97
views
Segmentation fault occur in function when passing char* instead of char[] during equation. How can I get access to char* literal? (avoiding read-only)
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;
}
...
1
vote
1
answer
87
views
Bun FFi function fails when I return a null terminated slice from ziglang
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 ...
0
votes
0
answers
22
views
How to Building Strings Unicode from C for mysql
I'm working with mysql in c, and I want to build a select statement with condition that uses unicode text :
char sql[2000]="SELECT * FROM accounts WHERE accounts.loaihinh='Đã xác thực'";
...
0
votes
1
answer
70
views
I need to create a malloc array of strings and print those strings out
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 ...
1
vote
1
answer
78
views
Is there a worked example of using CStrBufT with a CString?
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
...