Questions tagged [char]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
548 views

Invalid operands to binary expression ('std::string' (aka 'basic_string<char>') and 'char')

int main(){ int t; cin>>t; while(t--){ int n,sum=0; cin>>n; string s[n]; for(int i=0;i<n;i++) cin>>s[i]; int dec_value = 0; // Initializing base value to 1, i.e 2^0 ...
Abhishek kumar Singh's user avatar
0 votes
2 answers
269 views

defining a char variable, why am i getting this error?

#include <cs50.h> #include <stdio.h> int main(void) { int height; do { height = get_int("height: "); } while (height < 1 || height> 8); const ...
mandle565's user avatar
0 votes
1 answer
4k views

Error: format specifies type 'char' but the argument has type 'string'

This is the code written: #include <stdio.h> #include <cs50.h> int main(void) { string name = get_string ("what is your name\n"); scanf("%s", &name); printf("%...
Splendid Digital Solutions's user avatar
0 votes
1 answer
197 views

String to Char in C

How can I convert a String to a Char in C? Please help. I am unable to do that and I need it urgently. I need it for readability.
Saara Luthra's user avatar
1 vote
1 answer
720 views

Pset5: strcasecmp doesn't return 0 when given the same string input

// Implements a dictionary's functionality #include <stdbool.h> #include <strings.h> #include <string.h> #include <stdio.h> #include <stdlib.h> #include <ctype.h> ...
Uzayer Masud's user avatar
0 votes
1 answer
84 views

Try to use += on string to stack char(s) in C

I know it sounds real stupid, but It is cuz I just lightly learned Java and Python last year... now I am try to do C properly with CS50. on week 2, there is Caesar encipher text program task. I ...
Minsu's user avatar
  • 5
0 votes
1 answer
45 views

While defining a string using char*,how does it know where to stop?

when we define a string like char *name = some_name; and then print it printf("your name is %s",name); how does know where to stop while printing as we didn't include a '/0' at the end?
Rohit Jain's user avatar
0 votes
1 answer
32 views

PSet2 why isn't this providing output

This segment of code only prints out blank lines. Key is the correct integer, but I must be handling the array of characters incorrectly. Thoughts? int key = atoi(argv[1]); for (int i = 0, c = ...
KayO133's user avatar
  • 33
0 votes
1 answer
2k views

Incompatible pointer types even though they are both char*?

dictionary.c:70:20: error: incompatible pointer types passing 'char *[46]' to parameter of type 'const char *' [-Werror,-Wincompatible-pointer-types] if (strcmp(checker->word, lowword) == 0) ...
William George Bangay's user avatar
0 votes
1 answer
70 views

Vigenere Pset2 ciphertext question + others

(Main question- need help on this for code to work! highlighted in screenshot.) My PSET2 code works fine up until asking the user to input plaintext, but becomes funky and outputs blank spaces as the ...
chocopie645's user avatar
0 votes
1 answer
140 views

Pointers: What is the difference between char * <name> = .... and char* <name> = .... in assignment operations

In problem set 5, there are these two lines of code. char* dictionary = (argc == 3) ? argv[1] : DICTIONARY; ... char *text = (argc == 3) ? argv[2] : argv[1]; Both of theses operations seem to define ...
Peter Szujewski's user avatar
0 votes
1 answer
75 views

pset 2 initials: trouble printing only first char and char after space

So here is my current approach. I'm struggling with printing only the first character and the first character after a space in the problem. I feel like I'm pretty close but can't seem to figure out ...
Matthew William Hans's user avatar
1 vote
1 answer
12k views

C: Vigenere - incompatible pointer types passing 'char **' to parameter of type 'const char *

I'm trying to iterate repeatedly over key (a word) which the user inputs on the command line. This keyword is used to encipher a word which the user inputs when prompted by the word 'plaintext'. I ...
Android1's user avatar
0 votes
1 answer
221 views

C: Trouble with isalpha and char* - Error: expected expression

I am receiving the error: expected expression with this line of code. if(char* i in (word[i]) isalpha) { I need to iterate over the characters[i] in a word entered by the user. First I need to check ...
Android1's user avatar
1 vote
2 answers
281 views

Help with converting 2 or more chars to a single string

I am trying to convert two or more chars into a single string. Is this possible, and if so, how might I go about this? (BTW I am new to programming...)
Jason_V's user avatar
  • 182
1 vote
2 answers
210 views

Trying to Increment Characters in a String

I am trying to increments the chars in my string (ie string x = (aaaa) all the way through (zzzz)). Is there a specific way I can use a loop to do this? I'm sorry if my question is newbie, I'm new to ...
Jason_V's user avatar
  • 182
1 vote
2 answers
55 views

warning: deprecated conversion from string constant to ‘string {aka char*}’ [-Wwrite-strings]

I'm a complete beginner who just commenced on the CS50 course through EDX. While tryin out the walkthrough lessons in the CS50 IDE (clou9), I'm getting the following warning "TEST.C: In function ‘...
Muhammed Razeem's user avatar
3 votes
2 answers
14k views

What's the C equivalent for "string input = GetString();"

I am trying to become less dependent on the cs50.h library. I have tried different combinations to replace this line string input = GetString(); but I can't get anything working. Compiler keeps ...
Lele's user avatar
  • 67
0 votes
1 answer
186 views

What is the right way to pick the chars of a string and use them into a formula?

For Caeser I prompt a string from the user which I want to 'analyse' inside a for loop. Where I pick every char of the string and change the letters of the string. for (int i = 0, n = strlen(...
Kiwi's user avatar
  • 179
0 votes
1 answer
145 views

weird symbols in caesar

I'm almost done working on my caesar program, but whenever I try to print out a char, it returns a weird box symbol with numbers inside it or a diamond with a question mark inside, depending on the ...
K. Roe's user avatar
  • 19
0 votes
1 answer
448 views

c prog - Generate ''ALPHABET'' and ''alphabet'' in arrays, wrong output

I'm trying to generate two independent characters arrays. The first one must contain the alphabet in lowercase and the second one, in uppercase. My code works but in the second case, the output ...
CharlesD89's user avatar
0 votes
1 answer
29 views

what is the funny symbol printed when char[] uninitialized

char name[20]; strcpy(name,"incredible hulk"); printf("%s\n",name); I get this funny symbol What does that represent?
lindsaymacvean's user avatar
0 votes
1 answer
233 views

Check function error integer to pointer conversion

I keep getting this error but am at a loss as to how to solve it! It's driving me crazy and getting frustrated with it. incompatible integer to pointer conversion passing 'int' to parameter of type '...
user7869's user avatar
0 votes
1 answer
270 views

Comparing chars

I'm trying to write some code that will take input, loop through the characters in the input, and print "hi" for every "a" that shows up in the input. I'm getting errors trying to compare the looped ...
Nathan Juan's user avatar
0 votes
1 answer
98 views

Question of inputing an array of char

I created a struct, it's elements are all char*. When it comes to asking inputs for these char*, i don't want to use GetString(), instead i tried scanf(). The output is definitely wrong. Here is my ...
hutmanew's user avatar
0 votes
2 answers
610 views

different between pointers and pointer to arrays?

difference between -- char a[SIZE]; //Char array of size (SIZE) char *a; //character pointer. Points towards a char (a). char *a[SIZE]; // Array of pointer characters. char *(a[SIZE]); // Pointer ...
Prateek Pande's user avatar
1 vote
1 answer
75 views

fgetc with sleep unexpected result

I want to know why this code instead of writing a letter each second waits to read all the letters before printing them. #include <stdio.h> #include <unistd.h> int main () { FILE *fp;...
user avatar
1 vote
1 answer
70 views

In breakout, why use 12 char to store an int?

Here says: Why did we allocate an array of size 12 for our representation of that int as a string? No worries if the reason’s non-obvious, but give some though as to how wide the most positive (or ...
RexYuan's user avatar
  • 309
-1 votes
1 answer
761 views

Main difference between char & string, can they be used randomly

Using characters & strings, we normally write char{a,b,c,d} and string(a,b,c,d), what is the main difference between them, can we use them interchanging their positions?
PRADEEP's user avatar
  • 11