C is a good langua-

>C is a good langua-
#include
#include
#include

char a[15];
char b[15];

int main (int argc, char **argv)
{
strcpy(b, "abcdefghijklmnopqrstuvwxyz");
printf("a=%s\n",a);
printf("b=%s\n",b);
return 0;
}

Attached: toph.jpg (345x194, 33K)

Other urls found in this thread:

youtube.com/watch?v=FY9SbqTO5GQ
lkml.org/lkml/2017/7/14/637
youtu.be/ALvssgCcdPQ?t=170
twitter.com/NSFWRedditGif

Look mom! Little dumbo figured out c isn't good with strings. What's next? You tell us pointers are dangerous?

Why are millennial like this?
You use perl for strings idiot. C for everything else. Bash if need glue. Php for netheads. Lisp for homeless

nigga its just a sequence/array of characters
it aint complicated

Weird list of relics bucko

C and Unix single-handedly destroyed 50 years of computer science research.

>write bad code
>get buffer overflow
what did you expect was going to happen?
the language didn't write your buffer overflow, you did.

Attached: yeah_i_program_java.png (720x720, 488K)

>You use perl for strings idiot
are you retarded!? real C boys know you use awk for text processing and c for everything else user jesus christ don't mention perl in this pure thread good lord!

>compiler doesnt catch something this obvious
>defending a language that lets you hang yourself
baka desu senpai

>TFW JAVA DEV
been there bucko it sucks. finally got out and got me a comfy embedded job

>blaming the language for the compiler's lack of error checking
just because morons will hang themselves with rope doesnt mean we need to all use moron-proof rope

C is great if you approach it as high-level assembly.

Iz problem?

>the compiler doesn't bugcheck my code for me
Go back to Swift or whatever garbage you are used to

>C is great if you approach it as high-level assembly.
to be fair C stands for: C Mom! I made a single abstraction from asm!

Attached: dennisritchie.jpg (220x282, 38K)

>buffer overflow
>bug
:/

Looks fine if I compile it with g++

my output:
a=
b=abcdefghijklmnopqrstuvwxyz

>single abstraction from asm
I know you're meming but the few abstractions C has chosen make it at least 10 times more productive than x86 assembly, while still staying close to the metal.
I love C. RIP based ritchie

Yes indeed. C is my favorite language to write in even though it lacks a lot of the modern conveniences that newer languages afford us. However I can't find the performance that I can get with just plain old C. It's beautiful. God Bless Dennis Ritchie for gracing us with such a wonder ful language. Truly a based man. He is missed.

>what is asan
-fsanitize=address will find this easily.

Attached: 86457fc8e97c6efdd01a8f24a4ee151bf8af631b.jpg (500x469, 84K)

C is the best language.
#include
#include

#define size 15
char a[size] = {0};
char b[size] = {0};

int main()
{
strncpy(b, "abcdefghijklmnopqrstuvwxyz", sizeof(b));
if (b[size-1])
b[size-1] = 0;
printf("a=%s\n",a);
printf("b=%s\n",b);
return 0;
}

The only thing allowed to cheat Unix philosophy is C.

how so

a is unitialized, so that code isn't even using strings safely.

?
Turing -> C/Unix -> everything in the real world
Lambda -> Lisp -> fun academic stuff

those things peacefully coexist (and you can enjoy both)

I'm sorry, what?

you did not just associate turing with c, interchange it with unix, and disassociate turing from lambda and academia.
no fucking way. Is this the average CS major?

If you can't follow that train of thought please remove yourself from Jow Forums. Thanks.

It's just sad that strncpy returns the value of bytes it WOULD have written

This grouping has no logical flow to it

RETURN VALUE
The strcpy() and strncpy() functions return a pointer to the destination
string dest.

Attached: 1422422165257.png (722x768, 296K)

so what would be the best way to manipulate strings in C? someone mentioned awk, but what's the standard way?

youtube.com/watch?v=FY9SbqTO5GQ

Avatar is an utterly shit anime, retard.

>you did not just associate turing with c
why wouldn't I? TM are a good model of computation as we know it. Closer to reality than Lambda calc.
>interchange it with unix
C/Unix mainly quotes the shitpost I responded to. But of course you can't talk about C without talking about Unix.

>Cook
>listening to the Google security moron who's had his shit patches criticized by Linus on multiple occasions

>p-pointers are dangerous!
So is drinking water. Just don't be a retard and drink several gallons at once, and you won't die. ;^)

>C has chosen make it at least 10 times more productive
Stop speaking in absolutes. There are people that will be more productive on assembly versus c and vice versa. It all depends on if they know what they're doing, and how fast they can type.

Zoomers don't do use arrays anymore, they use

List list.

>not strlcpy
kys, would be lifetime autoban from my repos

who didn't have anything criticised by Linus?

>strlcpy
lkml.org/lkml/2017/7/14/637

And C++ for performance.

>the state of \g\

Attached: 1549775476669.png (1063x1063, 245K)

>if (b[size-1])
> b[size-1] = 0;
Useless check

fn main() {
unsafe {
*std::ptr::null_mut::() = 0;
}
}
RUST BTFO HOW CAN RUSTFAGS EVER RECOVER

Attached: pepe mic.jpg (511x671, 41K)

Who cares.
You exactly know in any case how many characters you have actually written.
The only thing you want to know, is if maybe you should have written more because n was too small.
By returning the number of actually written bytes instead you just lose information for no reason.

>what is speculative execution
A conditional branch is faster than storing null each time.

> >compiler doesnt catch something this obvious
warning: ‘__builtin_memcpy’ writing 27 bytes into a region of size 15 overflows the destination [-Wstringop-overflow=]
strcpy(b, "abcdefghijklmnopqrstuvwxyz");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

But it is conditional against some memory address, no register so should be slower, right?

>what are initialization rules for statics

>If an object that has static storage duration is not initialized explicitly,
>then:
>— if it has pointer type, it is initialized to a null pointer;
>— if it has arithmetic type, it is initialized to (positive or unsigned) zero;
>— if it is an aggregate, every member is initialized (recursively) according to these rules;
>— if it is a union, the first named member is initialized (recursively) according to these rules.

>what is undefined behavior
inb4 youtu.be/ALvssgCcdPQ?t=170

I never knew globals are stored statically. I thought they were placed somewhere on top of the stack before main or something

>write intentionally bad hack
>OH GOD WHAT A TERRIBLE HACK
>C is a good langu-

need directions to the gas chamber or you can at least get to there?

Unironically this is the direct translation of the C program to Rust
static A: [u8; 15] = [0; 15];
static mut B: [u8; 15] = [0; 15];

fn main() {
unsafe { B }.copy_from_slice(b"abcdefghijklmnopqrstuvwxyz");
println!("a={}", std::str::from_utf8(&A).unwrap());
println!("b={}", unsafe { std::str::from_utf8(&B).unwrap() });
}


>thread 'main' panicked at 'assertion failed: `(left == right)`
> left: `15`,
> right: `26`: destination and source slices have different lengths'

*high level assembly for the PDP7

Wrong, Lisp's homoiconicity is incompatible with the referential transparency of the Lambda Calculus.

There's compilers which catch that

c is the language of scumbags, every line written makes more work for someone smarter when they have to fix it later

>sucks ass at programming
>blames the language

Unironically most zoomers don't even know what's a variable and an array, nowadays they have let, dictionaries and lists.

Attached: 359.png (174x231, 16K)

>claims C is shit
>posts undefined behavior

>hurr durr im bad at programming so the language is bad!

Church fags should die. BASED TURING

I don't see why you are accusing zoomers, considering all that stuff existed long before C.

>Is this the average CS major?
Yes. Most CS majors I've met literally believe C was the first high-level language after assembly.

Horrible post

>needing the compiler to hold your hand
typical brainlet

You fucking niggers, HolyC is proof of what was destroyed that we could still have

HolyC is unironically a divine language because it combines the best syntax with full JIT. Everything is a file

I have no idea what this code does and I consider myself an artisan.

>I consider myself an artisan
That's why you don't understand. For those who exalt themselves will be humbled, and those who humble themselves will be exalted.

retard desu. If you ever looked at C you know what it does. First it copies a string longer than an array into it. Then it outputs it in addition to an array which never got data written on it

>C is a good langua-

fcuk off

>write shit code
>get shit results
who could have seen it coming?

Attached: 1529395455937.png (543x435, 128K)

>imagine not being able to count