Questions tagged [chararray]
51 questions
5
votes
2 answers
Does MATLAB provide a lossless coversion function from double to string?
tl;dr
I'm just looking for two functions, f from double to string and g from string to double, such that g(f(d)) == d for any double d (scalar and real double).
Original question
How do I convert a double to a string or char array in a reversible…

Enlico
- 23,259
- 6
- 48
- 102
2
votes
2 answers
How to store a char array (or part of it) into const char*?
I'm new to C++, and I'm having trouble to concatenate a const char* with a char aray.
First, I'd like to ask a question: Is const char* the same as std::string?
And going straight to my problem, this is what I'm trying:
I have this 10 sized char…

kuybt6
- 23
- 5
2
votes
1 answer
About Null character in C language
This is my program:
Click link to see the program
In this program,
char c[5] = "hello\0world";
When I print the string c using the following line:
printf("\nstring c=%s", c);
It gives the following output (with smile symbol at the end, not exactly…
user18325082
2
votes
1 answer
Why difference between 2 address is not multiple of element size
I couldn't understand why var is coming 6, how is it calculating
#include
using namespace std;
int main()
{
char *A[] = { "abyx", "dbta", "cccc"};
int var = *(A+1) - *A+1;
cout << "1: " << (*(A+1)) << "\n";
cout << "2:…

Hemant Kr
- 61
- 6
1
vote
2 answers
Segfault when using memmove()
I am working on a program written in C that recursively walks a given directory in order to print out the Nth largest files and their sizes in bytes. I am using two arrays to account for the filesystem entry names and filesystem entry sizes…

John Harrington
- 1,314
- 12
- 36
1
vote
2 answers
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 DEBUG_ERROR 5
#define MAX_DEBUG_LEVEL…

Dr.Random
- 430
- 3
- 16
1
vote
1 answer
CharArray joinToString keeps printing commas instead of S's
fun printRoom() {
println("Cinema: ")
val rows = 7
val columns = 8
val seats = CharArray(columns) { 'S' }.joinToString { " " }
for (i in 1..rows) {
println("$i" + " " + seats)
}
}
any help will be appreciated. Im…

Adam Adam
- 13
- 3
1
vote
1 answer
Issue with char array, contains garbage
I'm trying to run one of examples delivered by Raspberry for Raspberry Pi Pico. It is an example to read data from GPS module via I2C.
Raw data from GPS should be stored in a variable char numcommand[max_read], but instead of data from GPS, there is…

Dominik
- 25
- 5
1
vote
1 answer
Assign a char array class member using string literal
If I create my class like this:
class MyCLass {
private:
char name[25]{};
public:
MyClass();
MyClass(char name[]);
};
MyClass::MyCLass() {
stringCopy("", this->name);
}
MyCLass::MyClass(char name[]) {
stringCopy(name,…

Kotaka Danski
- 451
- 1
- 4
- 14
1
vote
3 answers
Problem replacing char in char array with a digit
Given a string, I have to replace all vowels with their respective position in the array. However, my code returns some strange symbols instead of numbers. Where's the problem?
String s = "this is my string";
char p = 1;
…

zaro
- 75
- 5
0
votes
0 answers
The char temp variable which is a triple pointer does not update after first iteration
I'm trying to make a university project. I am trying to store the ids of the user which are as u1,u2,u3.... in the temp triple pointer so that I can use them later but the problem is that for first time, i.e when i=0 then temp works fine and updates…
0
votes
1 answer
Encoding behavior difference either using char buffer alone or by converting to byte array char-by-char
I am developing a Java application where I get a value of type char[] from an external C++ dll.
There are cases in which non-ASCII values are expected to be input.
In such a case, it works normally when I construct a String by only passing it a…

hltu
- 3
- 1
0
votes
2 answers
Why is the output missing the first letter when I use strcat() in c++?
Here I want to merge two char arrays and put them into the first char array
But when I cout the second one, it is missing the first letter.
why?
#include
using namespace std;
int main() {
char s1[4] = "one";
char s2[4] =…

ahmad_ahmad
- 39
- 1
0
votes
1 answer
Why are there extra characters in my char[]?
I,m trying to shorten a char[] by a specified number, and for some reason, I've got more characters in my new char[]. Can you help me fix this?
When I tried with 1 or 2 letters, the result is this:
(the d, n, k, a are the first letters of each lines…

Đániel Labanc
- 3
- 1
0
votes
1 answer
Temporary string comparison with > and < operators in C++
These operators do not perform lexicographical comparisons and seem to provide inconsistent results.
#include
int main () {
std::cout << ("70" < "60") << '\n';
std::cout << ("60" < "70") << '\n';
return 0;
}
and
#include…

vss2sn
- 13
- 3