Questions tagged [datatype]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
18 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 ...
0
votes
0answers
15 views

PSET 3 Plurality Print_winner function prints smallest number of votes too many times (sorting algorithm?)

I am doing Problem Set 3 Plurality. I am currently on the print_winner function. My program compiles but I'm having issues because it does not print the winner and any ties it prints whoever got the ...
0
votes
1answer
38 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 ...
0
votes
1answer
74 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 ...
1
vote
1answer
96 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 ...
0
votes
1answer
86 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 (...
1
vote
1answer
330 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 ...
0
votes
1answer
36 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 ...
1
vote
1answer
206 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 ...
0
votes
2answers
155 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: ...
0
votes
1answer
36 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 ...
0
votes
1answer
87 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; ...
4
votes
1answer
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' [-...
0
votes
1answer
33 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 ...
0
votes
3answers
2k 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, ...
0
votes
1answer
62 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 ...
2
votes
1answer
3k 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?
0
votes
1answer
633 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) { ...
9
votes
2answers
346 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 ...