Questions tagged [char]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
37 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> ...
0
votes
1answer
9 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 ...
0
votes
1answer
32 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?
0
votes
1answer
26 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 = ...
0
votes
1answer
640 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) ...
0
votes
1answer
58 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 ...
0
votes
1answer
89 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 ...
0
votes
1answer
69 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 ...
0
votes
1answer
5k 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 have ...
0
votes
1answer
113 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 ...
1
vote
2answers
179 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...)
1
vote
2answers
192 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 ...
0
votes
1answer
32 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 ‘...
3
votes
2answers
7k 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 ...
0
votes
1answer
158 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(...
0
votes
1answer
120 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 ...
0
votes
1answer
327 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 ...
0
votes
1answer
25 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?
0
votes
1answer
186 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 '...
0
votes
1answer
186 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 ...
0
votes
1answer
91 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 ...
0
votes
2answers
414 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 ...
1
vote
1answer
63 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;...
1
vote
1answer
66 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 ...
-1
votes
1answer
337 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?