Questions tagged [atoi]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
2answers
934 views

CS50-pset2-Validating the Key-how to check or reject the user's input is decimal or not

Excuse me, When I practice the pset2 program, I follow the step at 'Validating the Key'. But I have the problem like below code, I want to compiler and output look like as $ ./caesar 20 Success ...
0
votes
1answer
138 views

atoi() always returns 0

** so the above is my code and here is the output i am getting after compiling the program. I can't understand why i is always zero no matter what input i give. please help me out as it might be a ...
0
votes
1answer
52 views

pset2 caesar, key is always zero [duplicate]

#include<stdio.h> #include<cs50.h> #include<string.h> #include<stdlib.h> #include<ctype.h> int main(int argc, string argv[]) { int i= atoi(argv[1]); string p = ...
2
votes
1answer
172 views

pset3 duration itoa - with “&”

For 'duration' I used the following which works (at least within a testing file), using atoi on individual parts of the inputted string fraction s: double n = atoi(&s[0]); double d = atoi(&s[...
0
votes
1answer
61 views

pset3 header.c atoi errors

I'm afraid to research too much because I don't want spoilers, I just want pointers. I'm getting a lot of errors, in particular atoi errors. I tried saving an array element as a char, but atoi still ...
0
votes
1answer
617 views

pset2 ATOI function

Hey guys just a quick question on the atoi function. In the Caesar walkthrough video with Zamyla, at around 06:00 she mentions investigating the "atoi" function in order to see what would be returned ...
3
votes
1answer
1k views

what is the difference beween atoi and (int)

What is the difference between using atoi(x) vs (int) x, given x = 10? I tested and found that: int main(void) { string x = "11"; printf("%i\n", (int) x); } returned 440546, whereas: int ...
0
votes
1answer
499 views

How to validate the key in caesar?

I just started working on caesar on pset2. I am having trouble creating an error when the user input is something that is NOT an integer in argv[1]. For example ./caesar hello. Here is what I ...
0
votes
1answer
268 views

atoi always returns 0

Every time I have used atoi it has returned zero. Here's some example code int key = atoi(argv[1]); and int atoi(message); Where am I going wrong?