[ 3 / biz / cgl / ck / diy / fa / g / ic / jp / lit / sci / tg / vr / vt ] [ index / top / reports / report a bug ] [ 4plebs / archived.moe / rbt ]

Due to resource constraints, /g/ and /tg/ will no longer be archived or available. Other archivers continue to archive these boards.Become a Patron!

/g/ - Technology

View post   

[ Toggle deleted replies ]
File: 73 KB, 240x240, 9BoqYqod0XMv84E4JU0tSwDIOCtnLRKF.png [View same] [iqdb] [saucenao] [google] [report]
60051693 No.60051693 [Reply] [Original] [archived.moe] [rbt]

char *str_array[]

Cfags will defend this

>> No.60051745

ITT: very high effort

>> No.60052007

It's a stack array of char * pointers.

What is there to defend?

>> No.60052114


There is no good reason type information should bind syntactically to the variable name instead of the type name.

>> No.60052162

Well that's good, because a pointer is not a type.
It's a pointer to a type.
For all practical purposes, all pointers are the same size, the only reason C even makes the distinction is so it can know what offset of bytes it needs to multiply by in order to retrieve array members.

>> No.60052196

I won't. camelCase.

>> No.60052234

This. Rust is the true anime language. Desuuuuuuuuuuinayyyyy ^.^

>> No.60052242

I'm a college dropout btw~

>> No.60052274
File: 40 KB, 232x254, 1480754565613.png [View same] [iqdb] [saucenao] [google] [report]

>when the language has proper strings

>> No.60052286

.png well played kind sir

>> No.60052322


>a pointer is not a type.
You cannot cast to something which is not a type.

>> No.60052347

>camelCase for locals
You deserve the worst.

>> No.60052375

camelCase for variables
UPPERCASE for constants
PascalCase for types

>> No.60052387

You're casting to a pointer of a type.
Pointers get special treatment.

>> No.60052437

PascalCase for types
UPPERCASE for macros
camelCase for functions
snake_case for variables and constants (that ain't macros).

This is the true way

>> No.60052462

functions are variables like any else

they're pointers to data

>> No.60052464


int *a = malloc(sizeof(int));
char *b = (int *)a;

In this code, what type does the cast operator take and what type does it return?

>> No.60052498

jesus christ i fucking hate C.

>> No.60052507

warning: initialization from incompatible pointer type

>> No.60052521

And? You don't call variables. You can make distinctions in whatever you want, just as if I want to use p_ for pointers m_ for memeber variables, etc... If you define a function, you name it with camelCase, otherwise is a variable and goes with snake_case.

>> No.60052548


>systems hungarian

>> No.60052570

Takes an int*, and then returns an int*, but since the return value is of type char* an implicid cast is done resulting in a warning.

>> No.60052590


Whoops, my mistake. I think it's clear what I was going for here.
int *a = malloc(sizeof(int));
char *b = (char *)a;

>> No.60052593

I agree, was just an example.

>> No.60052627

Well you really don't need to know what was the original type, now it's a pointer to char and that's all that matters.

>> No.60052661

> You don't call variables
On some processors, you can. You could actually manually compile regexes to char array and call that. There's no need to overcomplicate stuff and introduce a new concept for a function. Functions are just variables.

>> No.60052687
File: 19 KB, 250x250, 1444914295494.jpg [View same] [iqdb] [saucenao] [google] [report]

>using pointers for primitive data types

>> No.60052689


>an int*
>of type char*
>a pointer to char
Cool, glad we're in agreement here. So now the question has to be asked, if the types of a and b are int* and char*, why should * bind to the variable name rather than the type name?

>> No.60052766

For fucking christ, it's systantic stuff, if you can or you can't is the less of my worries, what I want to know is what a fuck that name is, and just saying "data" doesn't usually help.

I usually write it like this:
int* a = malloc(sizeof(int));
char* b = (char*) a;

It makes more sense, but again this is sintax, just do what you feel better with.

>> No.60052818


That notation makes sense, but it can be easily misleading.
int* a, b, c; /* int* a; int b; int c; */
This is why * should bind to the type name rather than the variable name. Pointers are, after all, a type parameterized on another type.

>> No.60052882

This never happens to me becouse when I create a pointer either I initialize it with something, or I initialize it with NULL. That makes it always one line per variable.
int* a = NULL;
int* b = a;
int* c = nullptr;

if you want one-liner:
int* a = NULL; int* b = a; int* c = nullptr;

>> No.60052919


Not a bad style either.

>> No.60053643

Who is this qt

>> No.60053724
File: 518 KB, 1200x800, kouchin.png [View same] [iqdb] [saucenao] [google] [report]


Kouchin from Oreshika

>> No.60055390

>all pointers are the same size
found the webshit

>> No.60055430

>On some processors
there are no processors

>> No.60055448

>This is why * should bind to the type name
and this is why you should learn c

>> No.60055452

#include <assert.h>
#include <stdio.h>

int main()
assert(sizeof(void*) == sizeof(char*));
assert(sizeof(void*) == sizeof(int*));
puts("hello world!");
return 0;

>> No.60055491


dude what?

>> No.60055496


>> No.60055497

you mean they are named memory addresses

>> No.60055511


Are you saying that it does?

>> No.60055547

no, I'm saying you don't know how declarations work

>> No.60055555

Address width depends on the architecture. E.g. x86 vs x86_64.

>> No.60055559

do you know what the word

>> No.60055561


Do share. It's what the thread is for after all.

>> No.60055577


Of course, but a char* is the same size as an int* is the same size as a void* etc.

>> No.60055625

Congratz anon

>> No.60055645

EnterpriseObjectFactory.Builder builder = new EnterpriseObjectFactory.Builder(EnterpriseObjectFactory.STRING || EnterpriseObjectFactory.ARRAY);

String[] array = builder.requestNewStringArray();

Java fags will defend this

>> No.60055672

You stole my repeating digits

>> No.60055679

>Implying similar C++ code doesn't exist

>> No.60055689


Pythonshits will defend this.

>> No.60055690

>assertion failed
hello, jscuck

>> No.60055720

>a char* is the same size as an int*
>is the same size as a void*
the char*, yes, the int* no

>> No.60055769

The standard doesn't guarantee this. See >>60055720

>> No.60055775


How come >>60055452 compiles and executes then?

>> No.60055795


I'm not surprised that the standard doesn't guarantee it but are there any real world cases where it doesn't work?

They are all just memory addresses, right?

>> No.60055797

it works on x86/x86_64 but isn't guaranteed to work on other architectures by the standard

>> No.60055800

something something implementation defined

>> No.60055827

you only tested one implementation

>> No.60055852 [DELETED] 

I am pretty much the smartest guy here btw

>> No.60056047

I slapped your mouth tho

>> No.60056300

C tards BTFO

>> No.60056385

kebab-case for everything, as LISP intended. It's the most racially tolerant way.

>> No.60058229

If you dont like C style strings then use an library, or make you're own string library. Fucking brainlets.

Name (leave empty)
Comment (leave empty)
Password [?]Password used for file deletion.