I bet none of you can answer a simple interview question:

I bet none of you can answer a simple interview question:

In C, what types are the following values?
a) 1
b) 1.0
c) '1'
d) "1"

Attached: CJS9Z6gXAAA53II.jpg (1200x675, 231K)

Other urls found in this thread:

play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=d845f8f894b6141d96a8b83ae5b244d8
twitter.com/SFWRedditVideos

a) int
b) double
c) char
d) const char*

W
R
O
N
G

did you delete this or did the mods do it for you?

Attached: 1551153199309.jpg (657x527, 38K)

1 is a decimal integer literal
1.0 is a decimal float literal
'1' is a char literal
"1" is a string literal (array of char ending with a '\0' char)
Next time go to /sqt/ for your homework.

int
double
int
char *

I deleted it because it went a) b) b) c) and it was stupid

Wrong. Learn C again

Impressive but not 100% correct

a) implementation-dependent
b) implementation-dependent
c) implementation-dependent
d) implementation-dependent

why would you care anyway

Attached: 1529177270558.jpg (319x331, 15K)

the char* is probably wrong. It should not be const char* though despite being static non-writable. I wonder if I can pull up some preprocessing bullshit to print types

Wrong, it's defined in the standard

There's two types of programmers. Those that don't know their shit, and those who know their shit

>In C
C is deprecated by Rust. I'll tell you what the types in Rust would be:
a) i32
b) f64
c) char
d) &'static str
play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=d845f8f894b6141d96a8b83ae5b244d8

unsafe{}

Attached: _$!(.jpg (831x961, 133K)

intrinsic functions are unsafe

Computers are unsafe

It's a trick question, because it's implementation defined. But on x86 using gcc it's:
a) int
b) double
c) int
d) const char*

op looked up some trivia and wants to act like a smartass

Because they are programmed in C/C++

char
float
char
char*

Those are not values but literals.

any of the answers in this thread are good enough if you are a programmer and not a bureaucrat
i'm sure you are proud of your knowledge of c but please don't be rude to the rest of us, we are all frens here

Attached: 1541349380120.png (409x409, 157K)

'1' defaults to int in C, char in sepples.
You people should know this.

Int
Nothing cause no 1.0f
Char
String

nah seems like such macro does not exist, but I was able to get types from error messages
int main() {
void *a = 1;
void *b = 1.0;
void *c = '1';
double d = "1";

which fails with
: In function 'main':

:2:12: warning: initialization of 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
void *a = 1;
^

:3:12: error: incompatible types when initializing type 'void *' using type 'double'
void *b = 1.0;
^~~

:4:12: warning: initialization of 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
void *c = '1';
^~~

:5:13: error: incompatible types when initializing type 'double' using type 'char *'
double d = "1";
^~~

Compiler returned: 1

although clang reports for "1" this message:
:5:9: error: initializing 'double' with an expression of incompatible type 'char [2]'
double d = "1";
^ ~~~

so that looks implementation-defined

>C
>String
r u retarded?

They are literal values

The actual answer should be char[2] so clang is correct

>should be
citation please

See: C standard

rangeban this bait faggot why is this still allowed here

ISO/IEC 9899:1999: 6.4.5.5
>For character string literals, the array elements have type char, and are initialized with the individual bytes of the multibyte character sequence;
I wonder when GCC decided on array to pointer decay

int
double
char
const char[2]

wow

Your program will not compile so they have no valid type.

None of them have types, variables have types not values.

They are all number one

int, float, string, string

please tell me how retarded am I

>&'static str
holy fucking shit

>4 bytes
>8 bytes
>4 bytes
>4 bytes, maybe 8 if the compiler automagically null terminates

>C
>string
user, I ...

nvm im a dumb, 4 is still 4 bytes even if null terminated

Computers are programmed in machine code.

Additionally, memory protection does not help stop sandbox escapes, which is what you should be worried about.

Another C riddle
typedef int* intRef;
int* a, b;
intRef c, d;


What are the types of a,b,c, and d. Don't look it up

A. DWORD PTR
B. QWORD PTR
C. DWORD PTR
D. DWORD PTR

Easy mode

a is int pointer
b is int
c is int pointer
d is int pointer

int *a;
int b;
int *c;
int *d;
don't typedef pointers retard

DWORD PTR

I don't know any C, but here's my guess:
a, b are pointers to ints
c, d are of type "intRef", which has an underlying type of an int pointer.
Am I in the ballpark?

Dear god no

Based and correctpilled for x86 and ARM

no see
Its completely retarded how c handles references though.

a is pointer to int
b is int
c is pointer to int
d is pointer to int

>C
>references

Had nothing to prove, proved nothing. Oh well!
Looking at the right answers I understand how it breaks down. Sad they didn't take the Go approach w/ right handed types + pointers. Makes things much more clear.

int, float, char, and string
I don't understand why this is supposed to be difficult.

>In C, what types are the following values?
>a) 1
>b) 1.0
>c) '1'
>d) "1"
It depends on how they are used and compiler implementation.
char a = 1;
char a = '1';
__int64 a = 1;
The closest answer I can give is a,b,c are single value and d is usually a array. Or in common terminology int[eger],float,char[acter],string

You obviously don't, as 3 out of 4 of your answers are wrong. The fact that you think C has strings it somewhat comedic as well.

Wtf am I reading.exe

Confirmed for not knowing what the fuck he's even asking about.

Safety costs cycles. Learn 2 code.

>i32
>f64
Your shit language will never run on a PDP-10.

The array type would decay to a pointer whenever evaluated in a scalar context, so GCC isn't wrong about thinking about it as a char * in the context of the assignment, which is what it's warning about.

To illustrate:
void a(void)
{
char c[2] = "1";
double d = c;
}

test.c: In function ‘a’:
test.c:4:16: error: incompatible types when initializing type ‘double’ using type ‘char *’
double d = c;

Why is '1' treated as an int and not a char? And why not an uint if anything. That would make more sense in relation to chars

You sound like those people from The Giver who are always saying "Precision of language!" Maybe it's just not that important whether I call something a string or a character pointer.

integer
double
character
string

Oh god, a liberal arts student. Shoo, shoo I say

No, actually I'm a NEET. But I've probably been programming for a lot longer than you have.

>C
>string

Attached: b04.jpg (800x857, 209K)

I doubt that

You wanna bet? I started in 2003.

Good for you, I started in 1999

I'm not a rust tranny but how is that any worse than * everywhere

Oh whoops, I didn't see it was C
Nevermind. Please continue

And you're still not past the "Look everybody, I know advanced computer stuff!" phase? Kys.

Wait, since when do values have types? I can declare "float a = 1;" for example, so it's not like 1 is intrinsically an integer. "What types are the following values" is a nonsensical question without an actual program provided as far as I can tell.

Literals have a defined type

>claim to be a progreammer 15+ years
>claim C doesn't have strings is some kind of esoteric, advanced knowledge for the privileged few

Attached: wtf-15.jpg (600x511, 84K)

Why? This is a stupid question.

You're pretty slow on the uptake when it comes to mocking, aren't you?

Also, all strings are implemented as character arrays or linked lists of characters, so claiming that C doesn't have strings because they're technically character pointers is just splitting hairs for the sake of sounding smart.

Not in C, literals have a type, and thank God for implicit casting or you'd end up like Rust. Also, any dynamically typed language.

Oh I see, thanks. Well I guess definitively answering OP's question requires quoting the C standard.

>something in memory
>something in memory
>something in memory
>something in memory

Save some money and hire an escort. It'll do you good.

1. number
2. number
3. string
4. string

>it's defined in the standard
There is no C standard. There is a lot of angry yelling tho.

Attached: 1515375000970.png (123x136, 39K)

&'static str
i know c++ has some idiosyncrasies especially with template syntax, but that's because the language was developed over decades and certain features had to be added while maintaining backwards compatibility. rust has been designed from the ground up and it's fucking hideous

> struct Number number = { .num_ber = 1 };
> so, this is the power of the C Programming Language

C, not Lua.

so what are the correct answers? i want to repost this in the future it would suck if i wouldnt know the answers myself

Attached: pooloo.jpg (550x335, 23K)

a) int
b) float
c) char
d) string (array of chars cause there's no string type in C)

Flax!

Attached: 1548051623473.jpg (184x184, 6K)

var
var
var
var

Based and c-pilled

Nope, you're completely wrong.

There's no string type in C user. You're wrong.

Data structures aren't types. The C standard library has functions for working with the string data structure. C doesn't have a string type.

number
number
string
string

get ownede boomers

int
double
int
char *