Questions tagged [datatype]

The tag has no usage guidance.

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

I want to understand the int data type. Why is the range 2^-31 to 2^31 - 1 when there are total 32 bits only. Should it not be 2^-16 to 2^16-1?

So my question may be very basic. But I am pretty new to computers. If there are 32 bits in the int data type then it means there are 32 places where we can write either a zero or a one (if I am ...
Abhinay Kumar Singh's user avatar
0 votes
1 answer
39 views

Segmentation fault: Data types for key and entered text by user while program operated through CLI

#include<stdio.h> #include<ctype.h> #include<cs50.h> #include<string.h> #include<stdlib.h> int main(int argc, string argv[]) { string enteredtext = argv[2]; ...
Splendid Digital Solutions's user avatar
0 votes
1 answer
26 views

Filter - Structures & Headers

The problem statement states that BMP files have a particular header with: (1) BITMAPFILEHEADER 14 bytes long and (2) BITMAPINFOHEADER 40 bytes long. bmp.h (provided) includes the definitions of the ...
LorenzoPeve's user avatar
0 votes
1 answer
42 views

ProblemSet1 - Another Credit.c issue - Can't convert the floating value of my variables into an integer value

I was almost finishing my code when I got stuck with a strange problem. I've asked a question a few hours ago and someone answered, so I manage to fix that issue. But unfortunelly I got stuck in ...
KevinWGS's user avatar
0 votes
1 answer
89 views

datatype string is malfunctioning in pset2 2020

I am currently working on pset2 cs50 2020. The Ceasar's cipher problem. I have managed the code for the first few steps and I think I know how to do the rest however I'm having an issue declaring ...
Renée's user avatar
  • 19
1 vote
1 answer
112 views

Return type of printf in C

In the video Data Types, Doug says around 6:50 that printf does not have a return value. I don't think this is true. printf does return the number of character printed on the screen. Here is a ...
user9026's user avatar
  • 113
0 votes
1 answer
92 views

pset1 credit.c – is this a data type conversion error?

TL;DR: My Luhn's algorithm function works flawlessly in JavaScript but not in C. In C, it ends up with the wrong total when multiplying every other digit. Could this be a data type conversion problem (...
Jinx Montague's user avatar
1 vote
1 answer
343 views

How does HEAD in linked list work?

I still can't figure out how HEAD in linked list works. What type of data is head? How can head be linked (connected) to the first note? That is what I have written, but still, don not know how to ...
wingedRuslan's user avatar
0 votes
1 answer
51 views

Limits of data type as explained in Week-1

In week-1 of CS50 course to introduction to computer programming, we are explained about the limitations of data types that are used in computers nowadays and how the computation 1/10 to 50 decimal ...
Arjun599's user avatar
1 vote
1 answer
208 views

Pset4 recover: can't seem to use struct to identify the jpg

Trying to apply the structs from pset4/resize. Coming up with a quick prototype to make sure i understand structs completely. 1) I keep returning nothing in my output. Can someone tell me what's ...
olafironfoot's user avatar
0 votes
2 answers
174 views

C data types and format specifiers

I was playing around with data types and format specifiers. Compiling the first snippet of code gives no errors but when I try to use unsigned shorts (or shorts in general) I get an error on line 12: ...
Alberto's user avatar
  • 21
0 votes
1 answer
37 views

Pointers & Integer Arithmetic Question

trying to do a simple exercise on pointers because my recover isn't working (and I think it has to do with pointers). Wanted to write a program that reverses digits using pointers. Unfortunately I ...
borker's user avatar
  • 301
0 votes
1 answer
104 views

difference between string, pointer, array and int

while it hasn't been something which really stopped me from learning, there is something which has been keeping me awake for the last few days... What is the difference between: #define x 5 int i; ...
Vincent's user avatar
  • 58
4 votes
1 answer
2k views

return value of sizeof()

In 'absolute beginners guide to c' chapter 13 printf("The size of in is %d.\n", sizeof(int)); but clang throws... warning: format specifies type 'int' but the argument has type 'unsigned long' [-...
lindsaymacvean's user avatar
0 votes
1 answer
41 views

Data compression: dictionary encoding

I am reading Computer Science: An Overview Eleventh Edition By J. Glenn Brookshear I believe this book was once assigned as optional reading material for CS50x A typical dictionary in a word ...
phillipsk's user avatar
  • 103
0 votes
3 answers
3k views

string variable is not working

I am trying to use a string variable after having included the header file stdio.h but for some reason it is not working. The color of the word "string" does not change as opposed to int, float, ...
Bilal Mallick's user avatar
0 votes
1 answer
113 views

Why using variable of double type for storing number of pixels? pset4

I have just realised that in pset4's short named "click" (at 2.30) here David prints out the coordinates of the click as floating point numbers. The number of pixels is finite so they could be ...
user avatar
4 votes
1 answer
8k views

sizeof(int) is 2 bytes in some computers, while it is 4 bytes in most modern ones. Why is it so?

What were the reasons for most computers which we work upon today to have an int of size 4 bytes? Does having a 4 byte int provide any efficiency for memory management, performance of a program?
Pooja's user avatar
  • 139
0 votes
1 answer
711 views

Pset4 error: invalid operands to binary expression ('double' and 'double (*)(void)')

The following error occurs in the lines where the velocity of the ball is initialized/changed using the drand48 function: When velocity is initialized : if(getEventType(event) == MOUSE_CLICKED) { ...
user1580's user avatar
9 votes
2 answers
697 views

What happens under the hood when performing a cast?

In the walkthrough example, ASCII-0.c, a cast has been performed to convert a number (integer in specific) to a character. I would like to know what exactly happens at the lower level when we cast an ...
Pooja's user avatar
  • 139