Questions tagged [char]
char refers to the character data-type, representing letters, digits, punctuation marks, control characters, etc. Use this tag for questions relating to and usage of the character data-type.
12,879
questions
-1
votes
0
answers
24
views
What am I doing wrong in this filing? [duplicate]
I am using the same char variable for the user to input his line into and as the image attached is showing, it won't take input from me the 2nd time or so on
void WritetoFile(){
ofstream r;
...
1
vote
1
answer
28
views
Comparing dynamically allocated strings in C
I'm working on a case where I'm dynamically populating a char array based on the return value of another function.
At some point, I would like to compare the incoming value to a static string and ...
-2
votes
0
answers
35
views
While loop argument doesn't work properly [duplicate]
#include <iostream>
#include <fstream>
#include <cstring>
#include <string>
using namespace std;
int main()
{
system("cls");
ofstream dat_in;
dat_in....
0
votes
1
answer
25
views
Can't figure out this segmentation fault
I'm quite new to programming and I am in the middle of doing CS50, and in this scrabble program I'm having trouble because I can't figure out which segmentation error I am making. It may be that my ...
1
vote
1
answer
37
views
If I declare the 'val' variable inside the loop then the code is not showing the desired output but when i put it outside loop it works fine. Reason? [closed]
In the below code, If I declare the variable val inside the loop then the code is not showing the desired output but when I put it outside the loop it works fine.
What can be the Reason?
#include <...
-1
votes
1
answer
34
views
C# -> 7 in a string, convert to int returns 55?
Evening... revising some C# coding questions///
10 Random numbers
7319018271
....so I put brackets around the numbers and made it a string...
created an array with [10]...idea is to iterate through ...
1
vote
1
answer
23
views
Serializable field value of Non-Roman Letter not working in Unity
[SerializeField] char _letter = 'a';
is working fine, assignable from the inspector
[SerializeField] char _letter = 'অ';
Unity just hangs. Any suggestions?
0
votes
2
answers
28
views
Why whitespace and empty string is same at mariadb?
As you know, whitespace and empty string is definitly diffrent each other.
BUT mariadb returns true at below code.
SET @whitespace = ' '
SET @emptyStr = '';
SELECT @whitespace, @emptyStr; # ' ', ''...
0
votes
1
answer
43
views
Random ABCD char generator
I am making a quiz game and want when the player calls his friend(which is a simple cout), the program prints a random char of an answe(A, B, C or D) and a random number to present how sure he is(from ...
0
votes
0
answers
26
views
Pandas: Dataframe as a function of another dataframe
I have a data frame which looks like this:
volume tenor NewTenor
0 12 year Cal 21
1 4 month Oct 21
2 9 quarter Q2 22
3 5 month ...
0
votes
1
answer
42
views
C# : how to convert char array into float [duplicate]
I have a byte array of four bytes which contains the byts of a FLOAT values.
For example
array[0]=0x1F
array[1]=0x05
array[2]=0x01
array[3]=0x42
this should be 0x4201051f, which means 32.255 value.
Do ...
1
vote
0
answers
39
views
Why does this code convert characters into ASCII numbers?
I have used this code and it works perfectly and simple, but I want to know how it works:
char caracter;
int m;
cout << "Ingrese un caracter : ";
cin >> caracter;
m = (int)...
1
vote
2
answers
87
views
What is a call to `char()` as a function in C++?
I've never seen this call to char() as a function before. Where is this described and what does it mean? This usage is part of the example on this cppreference.com community wiki page: https://en....
-2
votes
0
answers
33
views
C++ warning: ISO C++ forbids converting a string constant to 'LPSTR' {aka 'char*'}? [closed]
i dont know what to do. I just finished de code and i cant compile
The error is on this pi, but i dont know whats wrong : /
I dont have more to say...
That's it! Error:
C:\Users\Matheus Farias\...
-1
votes
2
answers
45
views
"Segmentation Fault" error when running MPI with more than one process - C++
I'm writing a Generator that generates words in parallel with MPI.
When I run the generator with a single process as below, it gives the desired outputs without any problems.
mpirun -np 1 ./bin/...
0
votes
1
answer
18
views
Python: Convert Months into Quarters conditional on second variable
I asked the same question for R and I obtained the answer, I hope to obtain it for Python too.
I have a dataset that looks like this:
tenor delivery_window
<chr> <chr>
1 ...
1
vote
0
answers
32
views
no match for 'operator+' in basic_string <char> and uchar
I'm trying to create a concatenated string using a basic_string<char> and a uchar* (unsigned char*). I'm running into issues and have tried every method possible.
My code looks like this at the ...
0
votes
0
answers
37
views
Program breaks after inputting anything other than numbers
So I made this Memory Game project using C for school. And after trying for quite some time I just can't fix that after putting any symbol instead of a number breaks the whole thing. I have tried ...
1
vote
1
answer
25
views
Split a cell that contains a phrase, placing each character of the phrase in a cell
I'm working with a 16 column x 4 row LCD display and to keep track of my project screens I'm saving it to a google sheets spreadsheet.
I would like to type a sentence and it already puts each ...
-1
votes
0
answers
46
views
C creating array of charachters and pointers
So basically, you receive string as input and what character is between the words in the string, (in this case ' '-space).
So this function should then create char** variable and then copy the ...
-1
votes
2
answers
30
views
passing argument 1 and 2 of ‘strcmp’ makes pointer from integer without a cast [-Wint-conversion]
Hello so I've been working a little prgramme which is sort of a calculator (I'm a beginner) and well as you can see in the tittle at then end of the code, the two if strcmp doesn't work. And vscode is ...
-1
votes
0
answers
70
views
Haskell comparing characters in a word
I'm trying to make a function that will check how many characters are matching in a word
The characters are non-repeating A-Z. The position of the letters doesn't matter
INPUT target = "ABCDE&...
0
votes
1
answer
49
views
C for loop suddenly stops [duplicate]
I'm trying to read distance between two nodes in a Graph and store it in an array but the loop doesn't work as expected. It suddenly stops.
Output:
Edge Number: 4
Enter distance between two nodes, ...
0
votes
2
answers
38
views
how to copy from char pointer one to anothe char pointer and add chars between
i want to write function in c that gets char pointer with sentence inside, and in every place there is comma ',' i want to add space ' ' after the comma
i write this function
char* ...
0
votes
2
answers
68
views
Adding two numbers stored as arrays of chars
I'm trying to write an algorithm which adds two numbers that are stored as chars in two arrays. Unfortunately, it doesn't work. When I try to debug it, I see that the variables a and b get the value -...
0
votes
2
answers
31
views
How can i split ArrayList<String> to ArrayList<Character> in java?
I have ArrayList of type String like ArrayList words = new ArrayList<>(Arrays.asList("hello","Monjed","Nidal"));
and i want to split this arraylist to type ...
0
votes
1
answer
28
views
rearrange the characters of a string so that any two adjacent characters are not the same
How to rearrange the characters of a string so that any two adjacent characters are not the same? using c#
c#
Without using Hashmaps and Dictionary
I managed to find each element of the string, and ...
0
votes
2
answers
47
views
Why fgets just have one line when i want to count the number of char
I tried this to count the number of char in a .txt that looks like that
ID2;Orelsan;San;Musiques\\Orelsan San.mp3
ID1;Rick Astley;Never Gonna Give You Up;Musiques\\Rick Astley - Never Gonna Give You ...
1
vote
1
answer
62
views
What is a properly way to iterate a char* string? Getting "corrupt" values [duplicate]
When I was trying to iterate a number (transformed to binary with bitset library) I managed this solution
#include <iostream>
#include <bitset>
void iterateBinary(int num) {
char *...
0
votes
1
answer
65
views
What can I store in a char?
I know that letters/one-digit-numbers can be stored in chars,
char letter = 'c';
char number = '1';
but can emojis or forgain letters be stored in a char? If not, how can I store them?
Is this ...
0
votes
0
answers
30
views
can't initialize "<" value to char variable [duplicate]
I was getting error message from c compiler ,when i tried to initialize "z" to char variable and tried to print using printf function,whats wrong with my code?
char a="<";
...
1
vote
2
answers
36
views
Count vowels in each of the strings using two dimensional array
I need to write a program where the user enters the number of strings and the program counts the number of vowels in each string and prints the total number of vowels.
The following code works without ...
0
votes
1
answer
19
views
How to convert a numeric variable to a character variable in SELECT statement (MySQL)
SELECT *
variable1,
variable2,
variable3,
variable4
FROM table
I wanna transform the variable1 from a numeric variable to a character variable, and I'm trying this options:
SELECT *
...
-1
votes
2
answers
43
views
another "initialization makes integer from pointer without a cast" error i didnt understand [closed]
This code is supposed to print valuesa and adresses of variables using variable and pointer names and adresses. I get this initialization makes integer from pointer without a cast error.
#include <...
0
votes
4
answers
62
views
How to access C++ map inner values
This is my map std::map<std::string,ProductInfo> mymap and these are the values inside ProductInfo:
bool isActive = false;
char name[80];
I am already able to access a specific key - value pair ...
0
votes
2
answers
73
views
c++ reinterpret_cast char to int* / adjacent bits are repeatedly set as 1100
Why does the second example find 1100 instead of 0000 after storing the address in the int pointer and then reading the adjacent bits?
Example 1:
char c = 'a';
int val = *reinterpret_cast<int*>(...
1
vote
2
answers
58
views
Wrong print values while iterating 2d char array
I am trying to run this code in Arduino IDE. It is printing wrong values.
char daysOfTheWeek[7][4] = {"Sun", "Mon", "Tues", "Wed", "Thur", "Fri&...
0
votes
1
answer
46
views
How to do basic encryption on characters (TypeScript)?
I want to encrypt a string with RSA public and private keys. However, when I try to decrypt the characters back to there initial ascii-value, they return something different. Here are my methods for ...
-1
votes
2
answers
66
views
Dynamic Memory for Char pointer Array
I'm still very new to C++, and I'm having issues with allocating heap memory.
This is what I have in my header file:
const int NUM_WORDS = 1253;
const int CHAR_SIZE = 256;
class CWords
{
public:
...
0
votes
1
answer
10
views
set non acceptable characters as a file name in py3
I'm trying to create some Images for characters and name them with that character.
this is my char list:
letters=["A","B","C","D","E","F",&...
0
votes
1
answer
18
views
Getting error as char cannot be dereferenced in java
Getting char cannot be dereferenced error , while writing following code
for(int i =1;i<=m;i++){
for(int j =1;j<=l;j++){
if(A.charAt(i-1).equals(B.charAt(j-1))){
arr[i][j]...
-3
votes
1
answer
33
views
I need a function to delete certain characters from a char array in c++ without using any index
for example:
if the user enters :
( 23+22+43)
I want the function to do exactly the following :
for(int i =0; i <strlen(x);i ++)
{
if (x[i]=='+')
{
deletfunc(x[i]);
deletfunc(x[i+1])...
-1
votes
1
answer
26
views
Printing strings and characters as hexadecimal in Go
Why cyrillic strings in hexadecimal format differ from cyrillic chars in hexadecimal format?
str := "Э"
fmt.Printf("%x\n", str)
//result d0ad
str := 'Э'
fmt.Printf("%x\...
-3
votes
2
answers
52
views
how i can convert char array to int without use parseInt and String.valueOf() (java) [closed]
need to convert char array to int without use parseInt and String.valueOf(),
need to realize this method
public static int parseInt(char[] str) {
}
for example, if the input data is char[] str = {...
-3
votes
1
answer
29
views
storing 2D char array created in a function
im trying to create 2D array in a function and that keep it for later use.
i have this:
char **add_to_list(char *str) {
char list[4][7];
int i = 0;
while (i < 4) {
if (i == 1) {
...
0
votes
1
answer
37
views
Why doesn't my program wait for another input?
I've written a small program to practice getting user input using getchar() and outputting it using putchar() in C.
What I want my program to do:
I want the program to ask the user to enter a char, ...
1
vote
2
answers
38
views
I'm having a problem with sending a char pointer to a function and assigning a value to it in C
I am trying to register to the address I sent to the function in the code structure you see below. But the for loop itself adds something. It only does this on arrays of 11 elements. That is, if "...
0
votes
0
answers
30
views
printf only printing correct value after copying string [duplicate]
I have following C code:
char* ToHex(char input)
{
char output[3];
char* HexArray = "0123456789ABCDEF";
output[0] = HexArray[(input / 16)];
output[1] = HexArray[input % 16];
...
0
votes
1
answer
41
views
How to make palindrome program using recursion ignore special characters in all places of the string in java?
I am having a slight logic error with my palindrome program in that when I insert special characters in the front or end of the string I get an indication that the string is not a palindrome. I am ...
0
votes
0
answers
17
views
How can I return a string from this function? [duplicate]
I'm new in C, and I'm trying to do a Student Record Management. These are just the main parts that I want to work, I want the string from fullName, to be assigned on fN[50]. Thank you!
char* ...