Most voted "char" questions
Char usually refers to a type of character data, representing letters, numeric digits, common punctuation signs etc. Use this tag for questions directly related to char data, specific methods and comparisons. For questions about String, use the specific tag [string].
Learn more…124 questions
Sort by count of
-
15
votes3
answers8488
viewsWhat happens in a conversion from a char to an int?
How it works when you take a variable and do char-48 To transform in integer, as for example in this code I made, I used a date for example "22/05/1994" stored in a char vector and transformed in…
-
9
votes4
answers459
viewsWhat happens when I convert int to char?
A whole has 4 bytes, whereas a char has only 1 byte. When I make that definition: int a = 1000; // 1111101000 char b = (char) a; I believe it will take only 1 byte of data, but what I want to know…
-
9
votes1
answer1019
viewsEncrypt a phrase/word by reversing and switching vowels with the following vowels
I was given an exercise in which I have to write a program that reads a word in the interval [1-20] and encrypt this word using the steps: reverse the word where there is a vowel, replace with the…
-
9
votes1
answer690
viewsWhy is it better to use char[] than String for passwords?
Using Swing, the method getPassword() of JPasswordField returns a character array char[] instead of returning a String like the getText() (which by the way is discontinued). I should not use String…
-
8
votes1
answer1179
views -
8
votes2
answers332
viewsHow does the computer "know" the alphabetical order when comparing two chars?
I have a question about Caesar’s cipher program: #include<iostream> #include<string.h> using namespace std; int main() { cout<<"Enter the message:\n"; char msg[100];…
-
7
votes2
answers1242
viewsHow to multiply an "X" character as many times as you want?
Is there a method that multiplies an "X" character as many times as I want? example: I have the character "P" P x 5 = "PPPPP" Is there any ready method in . Net?…
-
7
votes2
answers2251
viewsSizeof() or strlen()?
sizeof() or strlen()? What’s the difference in their use on char hands? which is more appropriate?
-
7
votes1
answer861
viewsFill char matrix with random words
I’m trying to develop an algorithm that can get an array of strings, sort by word size downwards, and put them into a char matrix by fitting all the words together if possible. The idea of…
-
6
votes4
answers11111
viewsConverting float to char array in C/C++
I recently took a test and there was a question that asked for a number like 123.456 was shown as 321.456. I thought the best solution would be to convert this to an array of char and then create an…
-
6
votes3
answers3711
viewsHow to shuffle characters from a Java string randomly?
I’m developing a password generator program. In it the user can set the percentage of numbers, letters and special characters that he wants to have in his password, as well as the size of his…
-
6
votes2
answers4614
viewsCharacter size (ASCII vs other encodings) in bytes
Seeing this issue a doubt arose, coming from PHP and in the past having "problems" derived from character encoding, ex: srtpos vs mb_strpos, i knew that all ASCII characters have 1 byte, but I…
-
6
votes1
answer7278
viewsHow to use the function toupper() in char in C?
I’m creating a variable: char nome[20]; After this, I am asking the user to enter a name: printf("Digite um nome : "); scanf("%20s",&nome); And I’m checking to see if the name is correct:…
-
5
votes2
answers764
viewsGraphic in Bars Char.js
Well personal I have a database query that returns an array of data. and wanted to put the values to be displayed on the chart in Bars. I tried this but with values coming from vector the graph does…
-
5
votes2
answers292
viewsHow do I compare an input in char with an interval (0 to 9) without specifying individual conditions?
I’m doing a show that reads a string and want to ignore the spaces and letters that the user type (but I have to read the letters i and p and the mathematical symbols +-/*^). What I have achieved so…
-
5
votes3
answers300
viewsCode for reversing sequence of non-vowels ending with zero status
I’m implementing the function decodificar, which aims to call auxiliary functions to reverse all non-vowel sequences. For example, if the word is "cool monsters," it will go to "mortsnol segais".…
-
5
votes2
answers1699
viewsHow to compare each character of a Java String?
I’m creating a Java application where I travel through one String with a bow for and I need to check every character of that String. Example: for (int i = 0; i < texto.length(); i++) { char…
-
4
votes1
answer315
viewsSQL Server CHAR and VARCHAR
I understood the difference between CHAR and VARCHAR. If I want to insert in a field VARCHAR(10) the word 'house', that word in the bank will take 4 bytes. If I want to insert in a field CHAR(10)…
-
4
votes1
answer1504
viewserror: initializer element is not Constant
I’m trying to declare this buffer overall and when compiling it presents the following error error: initializer element is not Constant char *ls_buffer_PPouAUT = malloc(5120*sizeof(char)); How can I…
-
4
votes3
answers546
viewsConvert char to integer in C#
Reading a blog article, I came across the following syntax for converting char to integer: string value = "123"; foreach (var c in value) { if (char.IsDigit(c)) { int digito = c - '0'; } } I wonder…
-
4
votes1
answer289
viewsChr$ equivalent function in C#
I’m migrating a chunk of code in Visual Basic 6 and came across the following call: variavel = Chr$(27) & Chr(15) 1 - What would be the equivalent functions in C#? 2 - What is the difference…
-
3
votes2
answers4471
viewsHow to Store Strings in Vectors - C
How do I store more than one name in a type variable char, why put, let’s assume name[20], I’m defining that she was given 20 characters, and not that she could receive 20 elements, the code I’m…
-
3
votes3
answers843
viewsShow the amount of each alphabet letter in a String
I’m doing an exercise in Java where the user enters with a sentence. After that, I have to list how many letters there are in the sentence, for example: Input = Daniel Henrique Exit: A = 1 B = 0 C =…
-
3
votes1
answer273
viewsHow to assign a character to a string position?
I’m having some difficulty assigning a character to a certain position of string. I researched a lot before asking here and found nothing. Criticism is always welcome. This function is a part of a…
-
3
votes2
answers767
viewsCompare String Elements in C
I would like to separate a word and compare each element of the string with a letter, I tried to make this comparison using the strcmp() but when executed seems to ignore it, or does not perform.…
-
3
votes1
answer74
viewsWhy char. Parse(string) returns a number?
I am making a program that uses Typecast, but when I converted a string to char (char.Parse()), received the following return: 115's' What is the reason for the conversion of string to char return a…
-
2
votes2
answers517
viewsProblem loading file to memory
I am trying to load several files into memory (small file), but the problem is that when I try to load another file soon after, all the files get the same name as the last uploaded file. I am using…
-
2
votes1
answer183
viewsLearn ABC in C language?
As I do in this code, when he type a letter read by the keyboard with the type scanf (char) it repeats until the Z? #include <stdio.h> #include <stdlib.h> int main() { char c; /*for (c=…
-
2
votes1
answer132
viewsChar count in C
I have a C function that should take a string, and pointers that have the amount of numbers and vowels that are present in the string, but the function is not adding up each time it finds a number…
-
2
votes1
answer646
viewscomparison using characters in c
Okay, the problem is only in function q31 and q311. http://pastebin.com/8CJwKej4 I left the complete code on the link above. then here is this function q311: void q311(){ char forma; int…
-
2
votes1
answer49
viewsKeeping names
I want to allocate a string within any structure that I can search for these strings after. I need to enter a condition to end the name insertion. I’m thinking of a structure that runs until the end…
-
2
votes1
answer3401
viewsConvert hexadecimal string to C-readable output
I would like to save a text in hexadecimal, and calling a function, the hexadecimal string is converted to a readable char string, i.e., decoding the hexadecimal, for example 0x6f0x69 for oi. I…
-
2
votes3
answers16313
viewsComparison of char in C
I need to find out if each element of a chained list is a vowel or not. How can I fix my code? int BuscaNv(LISTA* resp){ NO* atual = resp->inicio; while(atual){ if(atual->letra == 'a' || 'e'…
-
2
votes1
answer108
viewsC program to concatenate strings does not execute correctly
include int main(){ void concatenarStrings(char string1[], int t1, char string2[], int t2, char string3[]); char palavra1[]={'p','a','o','c','o','m'}; char…
-
2
votes2
answers71
views -
2
votes1
answer118
viewsType of char data needs space after quotation marks in the scanf
#include <stdio.h> #include <stdlib.h> void main(){ char elevador; int cod=0, a=0, b=0, c=0; while(cod == 0){ printf("\nElevador utilizado (a/b/c)? "); scanf("%c", &elevador);…
-
2
votes1
answer737
views -
2
votes3
answers161
viewsSize of a character array according to its addressing
Is the size of a character array given by its address or by the value of the variable? Example: char[1000] = "Exemplo Teste" The size of this variable is 1KB due to its addressing char[1000] or her…
-
2
votes1
answer7425
viewsFunction takes as parameter a string array
I just started learning the C programming language and I’m having a hard time. I declare a string vector, pass values to that vector and then pass that same vector as a function argument. The…
-
2
votes3
answers606
views -
2
votes2
answers165
viewsHow to take the first character of a String and make it uppercase by storing it in a variable?
String user,newUser,newPassword, password, resposta, user1,pass1; user = "admin"; password = "123"; Console.WriteLine("LOGIN\n"); body: Console.WriteLine("Ja possui…
-
2
votes0
answers321
viewsRemove accent from a string in C language
I’ve got a college paper on Threads and competition control (Openmp) in C, which is giving me a bit of a headache. The job is to take a text from any file and separate it between Threads producers…
-
2
votes3
answers111
views -
2
votes2
answers257
viewsRange of variables in C
I could never understand the question of the range of variables, I know that each one occupies a certain space in memory, but what does the interval mean? When I say a variable char assumes values…
-
2
votes1
answer108
viewsVariable char error C Visual Studio
I’m having problems using scanf_s in a char variable only in the visual studio. When it reaches the scanf_s line the program stops and brings me the following error: Exception thrown at 0x7893E63C…
-
2
votes1
answer44
viewsHow do I return a string from a char function? The returned value is NULL
I am having problems with creating a char function that returns a string typed by the user. I call her in a registration method and try to play for the struct variable. cadastrarLocacaoNome();…
-
2
votes1
answer68
views"strlen()" works with literal but not string type variable
I have this code: #include <iostream> #include <string.h> using namespace std; int main() { int len = strlen("Teste"); cout << len << endl; return 0; } That generates the…
-
2
votes1
answer70
viewsDoubt about C++ pointers
Why if a char type raw pointer is pointing to some character of a std::string and print this pointer without the asterisk (*) it will show the rest of the string from the character it is pointing…
-
1
votes1
answer248
viewsChar problem * and fgets()
I have a struct with a vector type field of char and I have a file .txt with several lines in this format with song names. text 1 text2 text 3 text4 I need to read the entire file row by row and…
-
1
votes1
answer375
viewsHelp: Valuing a char vector of a struct within an if
I’m trying to define the value of a char vector of a struct within an if, but without success... The struct itself: struct ficha { char nome[31], classificacao[31], telefone[21]; float altura, peso,…