Questions tagged [chararray]
51 questions
0
votes
1 answer
Numpy reranging chararray
How can one rerange chararrays without getting a TypeError.
import numpy as np
bggr = ([['B', 'G', 'B', 'G'],
['G', 'R', 'G', 'R'],
['B', 'G', 'B', 'G'],
['G', 'R', 'G', 'R']])
test…

StraightFoward
- 13
- 5
0
votes
0 answers
I need help iterating through an Array and inserting a new element in the correct position alphabetically by last name
I am practicing inserting and shifting arrays, I have a Contacts program and currently trying to write a function for adding a contact and inserting that contact in the correct position based on their last name
Note: I do not need to do any checks,…

Valkonaan
- 1
- 1
0
votes
2 answers
Capitalize each word in a string, how does this code check the previous space
I recently came across this solution to writing a program that capitalizes each word in a string and I'm trying really hard to understand it, but I can't get over one hurdle.
public class test {
public static void main(String[] args) {
…

OliverZemo
- 9
- 2
0
votes
2 answers
2d char array with commands for a car and needs to be tracked java
Expert's help needed on Java 2d Array:
boolean flag = true;
while(true){
String consoleInput = in.nextLine();
commands.add(cmd);
switch (consoleInput) {
case…

MaSu
- 3
- 3
0
votes
2 answers
char array gives inappropriate and unworthy output [C array]
char array gives inappropriate and unworthy output. Here I was making a binary converter everything is well but the output like this
'a ■wô▀╓vè▄╨ 0000 0000 0000 0101'
Don't know why but I just want simply '0000 0000 0000 0101'. Can you tell me…

SUD pythonism
- 19
- 6
0
votes
1 answer
Would accessing a "\0" at the end of a char array result in undefined behavior in C?
In this snippet of code, is there anything that could go wrong?
int min(int x, int y, int z) {
if (x < y) {
if (x < z)
return x;
else
return z;
} else if (y < z) {
return y;
} else
return z;
}
int d(char* a, char*…

bedirhan
- 21
- 2
0
votes
2 answers
copying one string to another without using strcpy using while loop
So i recently stumbled on this code somewhere where it is copying one string to another using just one line of code with the help of a while loop , however , I am not able to understand as to how and why it happens-:
int main()
{
char…

Prakhar Shankar
- 21
- 6
0
votes
2 answers
Comparing two char arrays in Java
I am trying to compare two char arrays lexicographically, using loops and arrays only. I solved the task, however, I think my code is bulky and unnecessarily long and would like an advice on how to optimize it. I am a beginner. See code below:
…

Erik Kostadinov
- 1
- 1
0
votes
1 answer
Return char array C
I have a function that makes a string with a certain number of #. String is stored as in char array (at list I think this is it... I'm new to C). This string is generated inside a function called blocks. I want to know how to return it so I can…

Urban Županič
- 1
- 2
0
votes
1 answer
Is it possible to read character array elements into a struct using ```strtoul``` in C?
I'm working on a project for a class and I could use some guidance. I need to parse a character array into constituent parts - the specifications of which I am given - but I am unsure how to do so in C.
I have been given a file and each page of the…

Natalia Hassan
- 15
- 3
0
votes
1 answer
Is there a way I can store address of a string to a 2D character array
I am trying to make a program where it asks the user the number of shelves and number of positions on those shelves from the user then it asks the user where he wants to enter a product.
Now I got rows and columns figured out but I can't get the…

Qadees PC
- 13
- 4
0
votes
1 answer
reverseCase along with swap Integer in kotlin
I am trying to write an effective code to reverse Case in kotlin .
HeLLo 5worLD6 -> hEllO 6WORld5
5 and 6 are swap as they have equal difference
Initially I am trying to swap digit's but forEachIndex doesn't change in my existing list . Why?
val…

Taimoor Khan
- 541
- 4
- 20
0
votes
1 answer
C passing char array to a function and pointers
So, I'm having a difficult time wrapping my head around using arrays and pointers in functions.
I want to print the following array of chars using a function. I can print them outside the function with the for loop but when I pass the same code to…

David Hernandez
- 57
- 7
0
votes
0 answers
Building a char array with hex bytes from string values
I'm trying to build a char array that contains hex bytes on the fly.
I effectively want to create:
unsigned char myHexArray[] = { 0xfc, 0x48, 0x83, 0xe4, 0xf0, 0xe8...);
But I want to create it from a string like so:
std::string str =…

Mike
- 61
- 5
0
votes
1 answer
How do I make my method count the character of 'a' in the main char array?
This was a problem involving an array of chars and uses recursion. I understand partly how to solve it, but I can't seem to output how many times the char a appears in the char array. Here is the method that I came up with two variations I tried but…

KennyatJava
- 15
- 3