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
-
1
votes1
answer2935
viewsSort Char vector in C using selection method
I am trying to sort a char vector using the selection method (Seletion Sort), but it is returning me the vector exactly the same way, without even making a change. Can someone point me to the error…
-
1
votes3
answers252
viewsArrays not started in C
How do I know how much size I have to put to scroll through an uninitiated array []? For example this one with char[]. #include <stdio.h> #include <stdlib.h> int main() { char texto[] =…
-
1
votes1
answer393
viewsCopying strings in C
I would like a help on the following question: I have a char with a text of 32 characters, so I would like to know how to separate this char in two of 16 characters. Type: char textao[32] = "Oi meu…
-
1
votes1
answer1337
viewsCharacter stack
Good night guys, all right? With my RPN calculator program here and apparently everything is working normal despite great difficulties to work with char stack.Missing implement the potentiation…
-
1
votes1
answer148
viewsInsert character by character of the Russian alphabet into a char vector in C++
Hello I would like to know how to insert characters (of the manual form) of the Russian alphabet in a char vector, because I am trying the form below and the problems in the press. Follows the code:…
-
1
votes3
answers473
viewsDoubt char C pointer
Hello. I need to make a pointer char point to a memory position holding a phrase, in C. I’m doing like this: char *ptr; char array[3] = {'o','l','a'}; ptr = &array; But I don’t understand what’s…
-
1
votes1
answer361
viewssystem() does not accept string type variable in c++
In order to automate some backups that need to be done routinely, so I thought of using an dos to do, but I’m having trouble compiling the executable because it seems to me that the function…
-
1
votes1
answer738
viewsComparison of char type variables
I’m developing a program that needs to read a variable in char and compare the same with another char. However, when performing the comparisons using the function strcmp(typed_pass, correct_pass),…
-
1
votes1
answer1259
viewsStruct vector and char pointer
Why is this syntax wrong: #include <stdio.h> typedef struct { char* nome; char* numero; }Agenda; void adiciona(Agenda* reg, int i) { scanf("%s", reg[i]->nome); scanf("%s",…
-
1
votes2
answers94
viewsHow to omit char matrix size in the function?
I have a question now, I have a function implemented this way: mostrarMensagem(char msg[10]) { //aqui faço algo com a variável "msg". } however I do not know the size I will receive as real…
-
1
votes4
answers25657
viewsHow to convert a char to an integer?
Convert a string for an integer with the function atoi() it’s easy, it’s not even? However, when I use the function atoi() to convert a character to an entire program that is running time simply…
-
1
votes1
answer2803
viewsCompare a char vector?
Good staff I have the following doubt why I can’t compare two char vectors using relational operators ? I know that vectors are a composite type and that the characters are in a static area I’m sure…
-
1
votes2
answers177
viewsWhy subtract -48 from a char and turn it whole?
I saw on another forum that guy subtracted -48 from one char and the char became a whole, because it happened? #include<stdio.h> int main(){ char num='3'; printf("%d",num-48); return 0; }…
-
1
votes2
answers928
viewsSegmentation failure (recorded core image)
I’m making a program for a simple purpose: Take a sentence and turn it into a version of it with the characters of each word isolated to the contrary, as: "I’m in trouble" would become "uotsE moc…
-
1
votes1
answer132
viewsWhat is the difference between *variable and *variable-'0'?
I’m writing a Sudoku game with C and ncurses, below follows the code of a function that receives a pointer to a variable (ch) which stores typed key with function getch(), if the number already…
-
1
votes2
answers659
viewsMaximum size of a character array
Has some maximum quantity, that a variable of type char character support? For example, I could use char texto[1000];? #include <stdio.h> #include <stdlib.h> #include <locale.h>…
-
1
votes1
answer41
viewsProgram in c++ hangs when I use a function to pick up a file name
I’m making a small IDE in c++ and I’m having trouble getting a file name. ex: the full file path is "Keywords//cplusplus.txt" but the file name is "cplusplus.txt". So I wrote a function to get his…
-
1
votes1
answer165
viewsPointer return pointing to a local character vector?
#include <stdio.h> char *local(void); void main(void) { char *ponteiro = local(); printf("%s\n", ponteiro); /*Saida = - (*/ } char *local(void) { char nome[12] = "programador"; char *ponteiro…
-
1
votes1
answer2701
viewsOn what occasions should I use an unsigned char or a char in C?
Recently I’ve been reading a little bit about the difference between a char and a unsigned char. I was able to understand the basic difference between the two, however, I didn’t get the idea behind…
-
1
votes1
answer821
views -
1
votes2
answers87
viewsConditional does not work as expected (related to ASCII table)
int tam, i; char msg[1000]; printf("Escreva a mensagem para ser criptografada: "); fgets(msg, sizeof(msg), stdin); tam = strlen(msg); for (i=0; i<tam; i++) { int aux; aux = msg[i]; if…
-
1
votes1
answer117
viewsC - Error reading a character using scanf(): scanf() command is "skipped"
I would like to know why my code does not accept reading characters, simply skip that step and perform the next. float altura, pesoIdeal = 0; char sexo; printf("Informe a sua altura : ");…
-
1
votes1
answer332
viewsSum of digits of a string only works when I do a subtraction I don’t understand
The program receives a string size up 10^6 and add the digits. I made the code, but to each loop 48 is added to the sum variable. If I modify the tenth line as soma = soma + nome[x] - 48 the problem…
-
1
votes0
answers129
viewsscanf and getchar()
why in the second printf I can use only op=getchar(); but in the end I need to use a scanf to realize the question? #include <stdio.h> #include <stdlib.h> #include <ctype.h> int…
-
1
votes1
answer436
viewsString error using the nextLine() method in Java
I have a problem with a simple java program. When I run and scan with String, it simply goes straight to the end of the program, but when I put char it does not pass and runs normally, even so I…
-
1
votes1
answer70
viewsDoes the char vector have a minimum size?
I’m doing a huge job and he’s given a bug very strange when allocating vectors of char with specific sizes. After a lot of headache I decided to do a small test. #include <iostream> using…
-
1
votes2
answers237
views -
1
votes1
answer51
viewsReturn string format from another struct
I wanted to return the formatted string, which is created in the function des_Desconto, to format another string of the function itm_showItem more does not return anything. Struct item struct item{…
-
0
votes1
answer1060
viewsC/C++ - Error comparing char with strcmp()
I need help, I’m having problems comparing two variables using strcmp(). [Error] invalid Conversion from 'char' to 'const char*' [-fpermissive] struct transicao{ int estado; //estado em que o DFA…
-
0
votes2
answers157
views -
0
votes1
answer152
viewsUsing Unicode in a variable char
Guys like me to use unicode in C? I just don’t know how to store the 2 bytes of one unicode on a char, that’s all, someone knows how?
-
0
votes1
answer797
viewsASCII value for char or Int value for ASCII C
Guys, I need to search for a value found by a rand in a file, I’m having a lot of problems because the rand returns me an integer and to fetch character in a file the fgetc me returns an integer…
-
0
votes1
answer3481
viewsFailure to read char with scanf ("%c")
Check this code to register two random matrices and then add, multiply... I want to put an option that every operation made the user has the option to quit the program, without going back to the…
-
0
votes2
answers319
viewsLike passing a Char to the bank?
How do I pass one Char to the Bank? Error Exception in thread "main" java.sql.SQLException: ORA-12899: valor muito grande para a coluna "SYSTEM"."USUARIO"."TP_SEXO" (real: 2, máximo: 1) at…
-
0
votes1
answer4109
viewsConverting char vector to string - C++
#include <iostream> #include <string> #include <vector> using namespace std; int main () { string vet[10], aux; std::vector<char> name; int count=0, sum=0; while…
-
0
votes1
answer268
viewsProblem with scanf in %d receiving a keyboard letter
I’m having a problem, I’m reading a int %d for scanf, but if the user type a letter the program enters loop. void chama_menu_switch(Fila **f, int n){ char confi; int i,y,x,a,z; double r; a = 0; int…
-
0
votes1
answer241
viewsI can’t compare char[]
I am running a server that I did in C and is working normally, with only one exception: I cannot create a condition for the received bytes. The Write and Recv function work normally but I am falling…
-
0
votes0
answers44
viewsFind char in a string, never find
I made a function search for a character in a string. The input parameters are the string and the character. The function returns 1 (one) if the character exists in the string or zero otherwise. The…
-
0
votes2
answers189
viewsHow to test if a string is a number in the C language?
I’m a beginner in programming. I am performing an exercise in which I must determine whether a character string is a number, considering that the user can write anything as input. So I created the…
-
0
votes2
answers337
viewsdetect repeated char in c++ string
Hello, I’m trying to make a code to detect the occurrence of parentheses Na(CO5(Pt Let’s assume something like, I would have to detect the position of the two parentheses that are in the string. I…
-
0
votes2
answers323
viewsFunction that returns next character in PHP ASCII table
I would like to make a function in PHP that would receive a character and return the next character, according to the ASCII table. For example: receives 'a' and returns 'b'. I know how to do this in…
-
0
votes1
answer24
viewsFunction to search character
I’m trying to write a function that returns the index of the character. For example, I want to fetch the index of 'a' the fifth time it appears in the text. This is my code: int buscaChar (String…
-
0
votes1
answer202
viewsChange a char array within a function
I am trying to pass a char array pointer to a function. I want it to make changes to this char array. Follow the function code: void dhnfe( char tzd, char hverao, char *dh) { if (hverao == 1) {…
-
0
votes1
answer323
viewsHow to take a char type die by Joptionpane?
char cadastrar; cadastrar = JOptionPane.showInputDialog("cadastrar: A-aluno P-professor M-medico");
-
0
votes1
answer255
viewsSomething equivalent to the sstream library from C++ to C
I need something similar to the stringstream you have in the C++ connection for the C language, I need it a lot because I want to make querys in a database using C (C mysql Connector). Since I had…
-
0
votes1
answer98
viewschar and constructors in c++
I need a constructor for a class that has char vectors as attributes, like this one: class Anthem { private: int Id; char Name[50]; char Country[50]; int Year; char Composer[30]; char Historic[200];…
-
0
votes2
answers1403
views -
0
votes1
answer55
viewsDoubt regarding string manipulation
I’m starting programming and was trying to do a string manipulation, someone could help me in the code below where I would be missing: #include <stdio.h> int main( int, char ** ) { char nome[]…
-
0
votes1
answer148
views -
0
votes1
answer108
viewshow to pass char from the main int to a class c++?
I’m struggling with how to pass a char type variable from the int main and play to a variable in the class. Example of the way I’m trying: class Nome{ private: char n[50]; public: void set_nome();…