How does Jow Forums format pointers in C?

1) char * text;
2) char *text;
3) char* text;

Discuss

Attached: image.jpg (1200x1276, 271K)

Other urls found in this thread:

youtube.com/watch?v=u_ij0YNkFUs
bing.com/search?q=jewish year 5779 is which year&form=IENTHT&mkt=en-us&httpsmsn=1&refig=6ef545506ab34365825a2613296c8acd&sp=2&pq=jewish year 5779 i&sc=5-18&qs=AS&sk=AS1&cvid=6ef545506ab34365825a2613296c8acd
twitter.com/SFWRedditGifs

char ^_^ text

4) I use a better programming language.

Attached: rustacean-flat-happy.png (1200x800, 32K)

Ambiguous code, char* is a pointer to a char, not 'text'.

The only valid form is the one that allows use of the comma operator.
char *a, *b, *c.

2 is the male way

extremely weak bait

Your shit language does not support strings.

char* is correct, because it's what compiler messages use.
the computer knows how to speak C perfectly, you're just a hillbilly that it has to put up with.

>the computer knows how to speak a human construct perfectly
>we're at fault when it disagrees

Attached: thonk.gif (300x300, 486K)

*char text;

typedef char * string;

is getting your dick cut off painful?

Option 3. Because it's nice to explicitly see that it's a pointer to char type data.

char *text or char * text don't really convey that information as clearly I think.

Option 2 if you're declaring multiple variables in a single line, especially if it's a mix of regular variables and pointers; option 3 if it's for declaring a single variable on one line.

2. for C
3. for C++
1. for retards

>better

Attached: 1568355969659.png (670x994, 90K)

based

What do you think

char* a, b;

does? Define two pointers to chars? WRONG. So stop writing it that way.

char *a, b;

Makes what you write look like what happens.

>std::wstring
widechar strings are not suitable for UTF8, use multibyte strings instead. Widechars are a mistake introduced by Microsoft back when they were on the committee in order to support their infinitely shitty character encoding.

Yes it does.

char *string = "Hello, retard!";

Piss off.

Rent-free.

1) multiply char by text
2) declare variable *text of type char
3) declare variable text of type pointer to char

c ignores whitespace dummy

wow, really?

based retard

Trips of truth. /thread

2 is the only correct answer.
char *p, c is much clearer than char* p, c, not to mention constantly reminding yourself that declaration follows us ekeeps your mental model of the language and your programs consistent, NOT TO MENTION it's how fucking K&R did it, which may as well be the word of God. Honestly, I don't think I've ever seen a piece of software worth running written in any other convention. You can definitely pin anyone who uses 1 or 3 for an irredeemable borderline computer-illiterate spastic.

Attached: Screenshot 2019-07-15 at 00.44.29.png (1146x708, 1.02M)

Here's a better question.

const char* or char const*?

Did you mean char *a, *b?
Because if you actually meant to declare a char and a pointer in one line, you should kill yourself.

>defending C with C++
>implying #include is remotely sane
>implying templates work and aren't absolute rhino shit
>using UTF-8 with 16-bit characters
>implying C++ doesn't make use of #include
>shilling C++20 after shilling against modules
>implying Rust doesn't have FP
>implying Rust's syntax isn't better than C++'s
>implying fast compile times are worth shit-tier safety in the year 5779
>implying binary size matters on desktop computers in the year 5779
>implying Cargo wouldn't still be thousands of times better than GNU Make even if it were half-finished
>implying Rust has no standard
>implying the BC doesn't simply enforce common-sense rules you'd already be following if you weren't a 12-year-old hacker wannabe
>implying the community matters to the technical details of the language
>implying there aren't trannies in C++ as evidenced in youtube.com/watch?v=u_ij0YNkFUs

Cniles have reached stellar-level damage control.

1. Denial
2. Anger
3. Bargaining -- (You) are here
4. Depression
5. Acceptance

Attached: rust lmao.png (600x600, 249K)

The pointer is a type, you dont have a char, but a pointer to a char in memory. The pointeris not even the sizeof(char) except on 8bit microcontrollers, therefore char*

>mixing pointers and non-pointers on the same line
Cniles, everybody.

Also, a c string is just a sequence of chars starting at the address of the first, ending with a null value.

Also2, the OP is about the suntax, not about a c string, so to ilustrate my point, considere byte* or bool*

obviously 3:
char* text;

>but muh:
char* text, character; // this does not go through any sane review anyway

you are a total idiot

see:

I don't know how to program in any language`

Cope

/thread

they aren't the same thing

template
using Ptr = T*;

Ptr text;

pic unrelated btw

I use 2. Even though I would never declare a pointer variable and a non-pointer variable on the same line, the example char *var1, *var2; clearly shows that, syntactically, the star "belongs" together with the variable name, not the type name.

Says the one who came into a thread that had nothing to do with their shitlang to shill it.

For declaration:

char* text

For dereferencing:

printf("%s", *text);

Explanation: the asterisk character is overloaded with three operations. Declarations of pointer values (first example), dereferencing of pointer values (second example), and multiplication. Distinction between the three operations is needed.

Multiplication should be handled the same as other mathematical operators, with whitespace on either side for readability. Declaration should be handled as pictured as in the first example since it groups the pointer value with the rest of the type and this type of spacing isn't possible for dereferencing without ambiguity with multiplication.

Rust is a replacement for C not C++. And C++ is not even a C replacement.

Why treat this one operator like it exists in a vaccum though? Isn't it enough to say that single-line declaration is ambiguous and should be avoided? Also, this is possible:

char* var1,* var2;

Of course this is ugly, but it shows that left-aligning the operator is also possible. Of course I also believe that multi-line operations should be avoided. It does not group the pointer declaration with the rest of the type, but that is only valid if you go by the model that the operator should be grouped together with the symbol that it can syntactically be placed next to. If instead you treat it as white-space alignment to avoid ambiguity, this is perfectly fine.

wchar_t

Yes they are.

char *const is different

Cope

Just do this

char* v1, *v2;

it's not like you see this shit very often

LPTSTR text;

Attached: images.jpg (225x225, 5K)

>char *c;
The value located at the address stored in c (*c) is a character

go to hell
char* is a type
text is a variable
*text is not a thing - it looks like dereferencing

Cannot implicitly cast const char* to char*. Plus, string is such that *string == 'H'. It just so happens that you can go out of bounds for a few more bytes without segfault.

> Cannot implicitly cast const char* to char*.

And that is bad how?

let text: &'static str

Attached: (JPEG Image, 201 × 251 pixels).jpg (201x251, 7K)

typedef chat_ptr char*;
char_ptr text;

>It just so happens that you can go out of bounds for a few more bytes without segfault
>it just so happens that you can't go out of bounds without going out of bounds

retarded take

Attached: 1560948711014.jpg (480x360, 10K)

> typedef chat_ptr char*

you had one job...

It's undefined behaviour.

I forgot how the typedef syntax goes because the only time i actually use it is:
typedef struct something something;
it was a shitpost anyway

3

LPCSTR

C strings are rubbish. C++ does it right. Fuck C for being needlessly obtuse. That's why there are so many buffer overflows related to strings.

Fuck off. You only pick on C because it's an easy target and Rust programmers are tranny-bullies. Your language exists because you are too much of a brainlet for C++, and cannot handle the power. Rust is a C++ alternative for diversity hires. C++ can do everything Rust can and more. If you honestly think that you are going to convince everyone to rewrite everything in your dindu dialation language, then you are dead wrong. We have the jobs, we have the skills, we have a much less toxic community. Your Mozilla Soros money is no match for our triple digit IQs and established dominance. We will win and are winning.

>C strings are rubbish.
>Fuck C for being needlessly obtuse.

c does not have strings, its just a pointer, and its the exact opposite of being obtuse, it is the most direct mapping of a high level language to underlying machine features, that's what the language was designed for.

A pointer to the beginning of some place in memory in which a bunch of bytes representing characters are stored is what it actually is in memory, and that's also exactly what it is in code.
Having some kind of string type would be the obtuse thing to do, you'd be pretending to have something you actually don't, any operations on this type would be obfuscated by a black-box layer of abstraction making those buffer overflow bugs near undetectable, while with regular c they're trivial to guard against.

I'd also like to remind you that c++ doesn't really have strings either, std::string is just a set of functions for handling these sorts of pointers. You could write these same functions in c to handle your strings and people routinely do, its just not included with the standard library.

A string is just a sequence of zero or more symbols over a finite alphabet.
The string libraries in many high level languages are just wrappers around cstrings and the string library functions. They aren’t magic.

holy shit imagine being this based

3. it's a pointer to a char, not a pointer to text. the other ways shouldn't even be valid syntax.

>1 character is 1 byte
Please no.

char*text;
whitespace is bloat

Attached: butt blasted.webm (640x360, 2.52M)

please say sike

God damn you are retarded.

The correct way, idiot

How is C a shit language?

I prefer 2, but could see why people would use 3 i guess. 1 is objectively wrong though

you're using it wrong newfag

Attached: anime0nazi.jpg (900x675, 66K)

Removing const breaks the code that depends on const correctness.
Idiot. There is absolutley nothing at all to even imply that a pointer to char is not NULL, let alone point to more than one byte. If C accepted arrays-of-chars as strings, you could check sizeof.
It doesn't facilitate writing abstract code with zero overhead - instead keeping your head in the dirt of implementation details.

>word of God
Dudes couldn't write a print function. Think about that.

/thread

>If C accepted arrays-of-chars as strings, you could check sizeof.
I don't understand what you mean by this? Are you just talking about how sizeof performs differently on arrays vs pointers since they are fundamentally different things (even though people will tell you otherwise).

lol

Attached: lol.gif (360x346, 170K)

nice, i like the symmetry
int* p
x * y
x = *p

>C++ can do everything Rust can and more
user you're not so anonymous anymore, you post this ridiculous claim on every thread phrased the same way along with somehow that you need to be smarter to use C++ than Rust? It has infinitely less concepts, the only "hard" thing in it is modern templates which are garbage and it's more obtuse than anything. You can really tell how threatened you feel typing this post too, you shouldn't let that show.
Oh and fuck off back to

sizeof can tell you the size of an array. e.g.
char str[] = "Hello, world!";
printf("%zu", sizeof(str)); // > 14
The problem is, arrays decay, losing their size information when turned into a pointer. It also isn't feasible to pass arrays by value if you don't know the size.
void bad_strlen(char str[]) {
printf("%zu\n", sizeof(str)); // prints sizeof(char*) regardless of str contents
}

To clarify, arrays in parameter position are essentially syntax sugar for pointers, hence why the size is unknown.

>you post this ridiculous claim on every thread phrased the same way along with somehow that you need to be smarter to use C++ than Rust? It has infinitely less concepts, the only "hard" thing in it is modern templates which are garbage and it's more obtuse than anything.
This is a baseless claim. The fact that it is backwards compatible with C makes it inherently more dangerous, even if safer and more elegant things have been added to the language.
>Oh and fuck off back to We were here first. Begone Reddit.

you can all just stop now an realize y'all have nothing on C#, C# is the future, Rust is but an experiment destined to fail and C / C++ are both long overdue their burial, it's time to wake up

This.

>year 5779
Everybody at least TRY to look surprised.

Attached: 1545766093323.gif (245x187, 716K)

Based

Welcome to Jow Forums, enjoy your stay.

bing.com/search?q=jewish year 5779 is which year&form=IENTHT&mkt=en-us&httpsmsn=1&refig=6ef545506ab34365825a2613296c8acd&sp=2&pq=jewish year 5779 i&sc=5-18&qs=AS&sk=AS1&cvid=6ef545506ab34365825a2613296c8acd

Year 5779

I mean really? Are you retarded? Do you have some magic pill that will save you and your basement PC from the sun exploding? Everything turning to dust? Death?

char *text is the only correct way

Kill yourself tranny.

>It doesn't facilitate writing abstract code with zero overhead
And all languages should aim for this because?
Sometimes you want to be able to look at the implementation details so you can optimise them for your specific case, and making C more abstract would just make that more difficult.
If you want abstract fast code, use C++ or Rust or something, not C.

>C#
>requires a runtime for everything
lol

They all do, but this one makes the most sense.
Option 1 is just too spread out, 3 will make you forget one * and break everything.

Like javascript?

based, you tell em user!

self contained

>OS is a runtime environment
>all languages running on an OS is now bad

hello hello hello
Jow Forumstards needs to die
die die die
nigger Jow Forumsredditors die now

Attached: trump.jpg (900x593, 110K)