Questions tagged [char]
The char tag has no usage guidance.
26
questions
0
votes
1answer
23 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.
0
votes
1answer
173 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
30 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
34 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
934 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
62 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
113 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
70 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
7k 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 ...
0
votes
1answer
125 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
210 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
201 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
38 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
10k 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
170 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
127 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
358 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
217 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
211 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
95 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
435 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
65 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
519 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?