Implying Sup Forums knows anything about programming

>Implying Sup Forums knows anything about programming

Other urls found in this thread:

en.wikipedia.org/wiki/IEEE_754
twitter.com/NSFWRedditGif

>implying Sup Forums is going to do your homework for you

>const char*
>char
>int
>unsigned int
>>???
>float

I don't know C but.... I'll guess

>array of char
>char
>int
>unsigned int
>unsigned double
>float

char* char int32 ??? ??? float maybe

Now do the same in html.
:^)

>string
>char
>int
>unsigned int
>probably an error
>float

>string
>C

String, Char, Int, Unsigned Int, Unsigned ??, Double

Fine, char[]

wrong

char array (char[]), char, integer, unsigned integer, ?, double

'0' is int you idiots

Do you feel smart and smug OP? Has this thread made you feel better about yourself?

Slightly

Types are considered on compile time, all those are literals if you put them inside your code like that. Still...

"0" -> literal, can be considered const char* if I remember correctly.
'0' -> character constant, can be considered char
0 -> numeric constant ,can be considered... signed int? I guess?
0u -> numeric constant ,will be considered unsigned int
0ud -> I have no idea if this even exists, but if it does it's some kind of unsigned
.0 -> Numeric constant, considered a float.

Stop - you have no idea what you're talking about

Ok enlighten me. I am more on the practical side and always respect the compiler warnings (you're not getting an implicit conversion warning from me). I know the difference between a string and a char*. I work with C daily so it would be helpful to point out the mistakes.

kys

>Types are considered on compile time
Rubbish
>all those are literals
Correct. Literals have well defined types, in normal code they are coerced to your chosen type.
>can be considered
I'll ignore these because it's wrong
>"0" -> literal, can be considered const char* if I remember correctly.
It's const char[]
>'0' -> character constant, can be considered char
It's int
>0 -> numeric constant ,can be considered... signed int? I guess?
Correct
>0u -> numeric constant ,will be considered unsigned int
It's unsigned
>0u -> numeric constant ,will be considered unsigned int
Nope. Unsigned long
.0 -> Numeric constant, considered a float.
It's double. Float would be .0f

char[2]
int
int
unsigned int
unsigned int
double

Probably all const if supported by the compiler.

Oh look, an idiot pretending to know things.

This is mostly correct. String literals are static and const. Character constants are signed ints. You are right 0ud isn't a thing. And all literals are const.

>Oh look, an idiot pretending to know things.
>This is mostly correct.

The first isn't const char[] idiot. It's static const char *. Now go fuck off.

char[1]?
char/int?
int (octal)?
unsigned int (octal)?
float?

Yeah, I should read a book.

Yeah, it is. Go read the specs, moron.

what's the difference between const char[] and const char* ? When you declare an array, the name is a pointer to the first element iirc. so an array is a pointer (to stuff in the stack iirc, but still a pointer)

They're interchangeable but they're NOT the same thing

Nope, GCC tells me it's a static const char *. Also 0ud isn't a thing. Unsigned long would be 0ul. L and d aren't next to each other so don't chalk that up to typo.

The main difference is that you can sizeof one and not sizeof the other.

ud doesn't exist. Otherwise correct.

>>const char*
>nope, its const char[]

u is unsigned int
>nope, its just unsigned

you do know that the compiler defaults types as int and double, right?

That's a simplification. Arrays are aggregate types, pointers are integers. That's why size of works the way it does. sizeof (pointer) is 4/8 bytes typically. sizeof (int [4]) is the size of 4 ints or 16 bytes typically. That's the difference.

...

To add, since arrays are aggregate types all the memory is allocated as one unit, contiguously. And you can count on that, it's in the standard IIRC.

Yeah. I think this what allows the C "array hack" or "struct hack" to work. Thanks to Microsoft, we'll never have official variable size arrays (C99). Feels bad, man.
Our replacement is this:

typedef struct {
int length;
long long content[1];
} varArray;

varArray* makeArray(int length) {
varArray *array = malloc(sizeof(varArray) + length - 1);
array->length = length;

return array;
}

int main(int argc, const char * argv[]) {
varArray *a = makeArray(26);
// can access a->length and a->content now. Writes on a->content until [25] will never overflow our array.

null terminated char array to be exact.

Honestly C-strings were a mistake.

C is a waste of time for your average software dev

>the absolute state of C objects
The fuck are you doing man just use C++

char [2], int, int, unsigned int, invalid, double.

const char *
char
int
unsigned int
unsigned decimal? I don't know
double

The best part is that you have repeat this for every fucking type you want a variable size array of.

I fucking love this language!

I've written variable array implementations in C without needing to generate a shitload of function declarations with macros.
struct dyn_array {
size_t len;
size_t capacity;
alignas(max_align_t) unsigned char data[];
};
You do need some macros to make the API a bit more plesant, so you're not constantly passing sizeof(type) as an argument.

(OP)
"0" -- char[2]
'0' -- int
0 -- int
0u -- unsigned int
0ud -- no such thing
.0 -- double

>char *
Wrong. It's char[2].
It just happens to decay to char * before you use it, most of the time.

Oh shit you got me.

>unsigned double
Please stop

>float
No, .0 is double. float would be .0f

If you are average, you are a waste of oxygen, to begin with.

why do I need to know that when C++ has auto?

4u

>not using stdint types

string
char
int
string
string
float

Why is '0' an int?
Wouldn't it be a char, since int is 4 bytes and char is 1 byte?

It fits into a char but it's defined in the spec as int

char []
int
int
unsigned int
invalid syntax
double

char[]
int
int
unsigned int
invalid suffix (GCC throws an error for trying to grab sizeof(0ud))
double

First of all, this is concerning C, not C++.

Second of all, auto uses the type of whatever is on the right hand side of it. So the question would be asking what is the type of a variable assigned to this with auto, assuming C had it.

Sup Forums isn't for your homework bud

Correct anons are correct

char*, int, int, unsigned int, unsigned double, double

>unsigned double

const char[2], const int, const int, const unsigned, const unsigned long?, const float

idiot

>be a casual
>use python
>don't have to worry about this turbo-nerd BS

multiply length - 1 by sizeof long long, brainlet

char *
char
int
unsigned int
unsigned double
float

>brainlets don't know that .0 means double
L U L
U
L

I'm also concerned about the amount of people that don't know that float literals end with f.

malloc(1)

VLA were made optional in C11 because embedded devs didnt want to implement compiler features they couldnt use.

const char*
int,
int,
unsigned int,
Not standard C
double

VLAs are not flexible array members user.
And flexible arrays are necessary to do something like this while being strictly compliant.

>Thanks to Microsoft...
Why are you using a C++ compiler to compile C?

const char*
int
int
unsigned int
double
float (?)

That's not VLA though....

char*
char
int
unsigned (int)
unsigned double
double

This is the only objectively true answer

"0" string
'0' another string
'0' int
0u unicode
0ud unicode decimal
.0 fraction

In C++ maybe, but not in C.

What the fuck is unsigned double m8

>string
wew

In theory it's a positive number.

en.wikipedia.org/wiki/IEEE_754

Who gives two shits about C?

>In C, name the types of
>In C
It's like you didn't even read OP.

5th one is actually undefined behavior.

>+ length - 1
Shit nigger what are you doing