[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/C General/

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 96
Thread images: 6

Let's go, boys.
>>
Why not use C++ you fucking plebs. stop trying to suck head cuck torvalds dick. Thx senpai.
>>
what's the purpose of this thread
>>
>>61137551

they're brainlets
>>
File: Screenshot_20170629-160959.png (112KB, 720x1280px) Image search: [Google]
Screenshot_20170629-160959.png
112KB, 720x1280px
Kek
>>
Ken Thompson is turning in his grave.
>>
>>61137713
Probs shot himself in the foot xd
>>
which is the better framework or toll for serch leak memory and errors? Im using valgrind
>>
>>61137551
holup... holup hollup.
*reads from stdio*

so you be sayin..
*overflows an int*

yous be sayin that C++ has TEMPLATES N SHEIT?
>>
ITT proof /g/ isn't anywhere near as good as they say they are. Just a bunch of blowhards fronting.. Just like /v/.
>>
currently learning SDL2.0 here
>>
>>61137551
Because C++'s name mangling and hidden virtual pointers fuck up the abi.
And you just know these fucks aren't gonna maintain their C bindings.

Anyone using C++ for making a library should be shot on sight.

And when you're building an application you're better of using a managed language.
>>
>>61137890
all the good posters from 10 years ago have been hired at amazon
>>
>>61137551
because C++ makes me puke
>>
>>61137890

gb2 hpg >>61134054
>>
>>61137890

during australian hours /g/ is popping with C and C++ programmers. it's only during american hours that people get bitchy because they can't contribute BECAUSE THEY DON'T KNOW HOW TO CODE LMAO
>>
>>61137528
How do I go about replacing C++ with C if the code isn't mine? Resources please.
>>
>>61137528
*segfault*
>>
>>61137808
valgrind is best

>>61138981
NullPointerException
>>
>>61137528
C actually looks like a patrician language to learn.

Right now I'm focusing on learning and practicing algos and architecture (is this the proper term?) And python but I'm definitely looking at C and then assembly in the future.
>>
>>61137551
Sorry, I was going to reply to you, but I made a mistake in template code and error LNK2019: unresolved external symbol "class std::basic_istream<char,struct std::char_traits<char> > & __cdecl >>(class std::basic_istream<char,struct std::char_traits<char> > &,class List<class NumString> &)" (?>>@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@std@@AAV12@AAV?$List@VNumStr ing@@@@@Z) referenced in function _main
>>
>>61137528
Is there library that provides only cross platform file and directory operations?
Fuck glibc for not supporting C11 threads.
Which portable general purpose library should be used: Glib, apr, tbox or something?
>>
>>61139254
>unironically using iostreams
>>
>>61139469
>no true sepples programmer
>>
>>61139469
oh, sorry for not using production code for generating these errors
>>
>>61137713
He isn't dead
>>
>>61139469
>unironically using non-standard library
>>
>>61140706
Which standard library??
>>
best current book for C?
>>
>>61140970
K&R, everything else is a meme
>>
What are some of the main differences between
GCC and LLVM Clang? And In what circumstances is it smart to use one over another?
>>
>>61141170
>What are some of the main differences between
quality
>GCC and LLVM Clang? And In what circumstances is it smart to use one over another?
it's never smart to use GCC
>>
>>61141170
If you're just targeting PC (x86 and x86_64) there's little difference. Clang has better error reporting, GCC supports more target platforms. Ignore memesters like >>61141191. GCC was really fucking bad a couple years ago, but it's amazing what a little bit of competition will do. I would say that if you're looking to write your own compiler front-end or back-end, LLVM is easier to work with than GCC.
>>
>>61137717
he is alive you dumbfuck and even he if he did shot himself in the foot he probably would not die
>>
>>61139906
I think he ment the other guy, Richie
>>
>>61137551
is there any real life scenario where the performance you gain from an unmanaged language makes up for all the wasted dev time to not make it crash and burn?
>>
>>61141249
This, but use GDB either way.
>>
>>61137918

>/g/ working at Botnet, the company

I don't think so, friendo.
>>
>coupe years pass
>c/cpp become mainstream in webdev due to wasm
will dpt neets ever recover?
>>
C needs to be reformed, C with classes?
>>
>>61143103
You either die a NEET, or live long enough to become the botnet.
>>
>>61143225

C++ by design instead of by evolution would be literally perfect.
>>
>>61141170
i wish there was a compiler that wasn't a bloated shitpile like gcc or clang but that still produced decent object code
>>
>>61143271
so, rust?
>>
>>61143271
This is a good point. The scientists watching C++ evolve will be in position to design the next best language.
>>
>>61143323
No, I'm thinking more like D but less revolutionary and keeping the focus squarely on systems programming.
>>
C is a disservice to intelligent programmers. It has almost 0 features that a modern and intelligent programmer uses to be productive. Since C is such a timesink, it's popularity is falling more than any other languages in the market.
C is dying and it should die ASAP. C programmers are actually retards in general. C is a small language to grasp, exactly the kind of shit that makes things retard friendly.
C has no advanced features like C++ does.

But as a newfag you are kinda in the right direction. C is for newbies. Think of it this way:
During ancient times, counting to 10 was a big deal and a person who could count to 10 was considered to be "wise".

Fast forward a few century counting to 10 is so trivial we teach this to toddlers. Now toddlers appreciate the vast "knowledge" of counting to 10 while matured brains are busy with modern technologies.

C is from stone age and the people who still preach it is like overgrown toddlers that can't learn advanced things. C is for lesser programmers.
C doesn't have delegates
C doesn't have resizable arrays
C doesn't have strings
C doesn't have string concatenation
C doesn't have namespaces
C doesn't have exception handling
C doesn't have closures in the standard
C doesn't have unit tests
C doesn't have Function overloading
C doesn't have memory safety of any kind
C doesn't prevent memory exploits and has no bounds and runtime checks
C doesn't support dynamic method loading/creating
C doesn't even have generics and templates
C doesn't have meta programming
C doesn't have mixins
C doesn't have higher order functions
C doesn't have contract programming
C doesn't have inner classes
C doesn't have function literals
C doesn't have array slicing
C has a very limited support for implicit parallelism
C doesn't even have string switches

C is a cancer that plagues the modern software industry
>>
>>61143434

>C doesn't have delegates
function pointers
>C doesn't have resizable arrays
realloc
>C doesn't have strings
const char*
>C doesn't have string concatenation
strcat
>C doesn't have meta programming
macros
>C doesn't have array slicing
offset your ptr and pass a different size_t, done.

I'm no C evangelist but you just look bad if you can't get your facts straight
>>
>>61143434
C speaks the language close to the CPU, not some made up bullshit that kills efficiency
>>
>>61143932
>what are zero-cost abstractions
>>
>>61143976
>what are zero-cost abstractions
fiction
>>
>>61143976

> He fell for a shitty slogan.

jej
>>
>>61143190
fucking webdevs are the most deluded retards on earth.
>>
>>61137528
>C general
>not one line of C
Guys, /dpt/ has the same disease. When are you really doing business? And by business, I mean, not the salesman kind of bullshit.
>>
File: 1489236549923.jpg (31KB, 500x600px) Image search: [Google]
1489236549923.jpg
31KB, 500x600px
>>61137528
can anyone explain to me how pointers work in very basic terms im a fucking retard.
>>
>>61145670
cannot fathom how you can fail to understand this
>>
>>61145670
It describes the location of something.
* means go to that location that the pointer describes, and & means obtain a pointer that describes the location of this variable.
int x;
int *y; // declare a pointer to an int.
y = &x // y describes the location of x.
*y = 4; // Go to the location y describes (which is x) and sets it to 4.
>>
>>61145744
cannot fathom how you can fail to understand how someone fails to understand this
>>
File: 1496410795304.png (102KB, 367x321px) Image search: [Google]
1496410795304.png
102KB, 367x321px
>>61145753
but why are they needed?why dont i need them in java for example?whats the point of pointing at something with your finger and saying its there?
im literally a brainded piece of shit but i just dont understand what is it used for.
>>
>>61145853

I am software, I need to look at a string.

Do you copy the entire string and send it to me or do you just say 'the string is there'

Consider which is faster
>>
File: 1494323868166.jpg (108KB, 1000x564px) Image search: [Google]
1494323868166.jpg
108KB, 1000x564px
>>61145914
so its only used for speed/memory purposes?is it serve any other functions?also thanks for explaining
>>
>>61145753
why the fuck everyone uses
>int *y
instead of
>int* y
?
Pointer to type IS ALSO the fucking type, it is logically way more fucking clear
Fucking disguting retards
>>
>>61145753
>>61145765
The problem with these examples and why generally people fail to understand what pointers are about is that they don't exhibit a concrete use case where pointers are pretty much essential.

Point in case: operation on arrays.
You want to print all elements of an array. The problem is, you don't know pointers. So, you write this function prototype in C:
void print_int_array(int array[MAX_ARRAY_SIZE]);

Where MAX_ARRAY_SIZE is an arbitrary value. But when you'll call the function, firstly it expects an array which is exactly of size MAX_ARRAY_SIZE, and secondly, the program will copy the whole array to the function stack (because in C, arguments are passed by value).

To be more generic, you only have to pass the location of the array and its size as parameters, in a base:offset fashion. This location is exactly what a pointer is. And your function prototype looks like this now:
void print_int_array(int *a, size_t n);

So you can pass an array of any size now.
>>
>>61145853

Java does (somewhat) have them, but it tries to hide it.
Observe the following Java code.
public class MyClass
{
public int variable;
};

...

MyClass a = new MyClass();
a.variable = 4;
MyClass b = a;
a.variable = 5;
System.out.println(b); // 5

the MyClass object isn't copied, only a pointer to it is copied. a and b both refer to the same object - so it's using pointers, it's just not obvious.
C ensures all pointer usage is obvious.

>>61145957

Learn how declarator syntax works, not how you wish it worked.
>>
>>61145957
Because
int* x, y; // x is a pointer, y is an int
int *x, *y; // both pointers
>>
>>61145977

arrays complicate things because of the subtleties of array decay, it's better to start with the familiar.
>>
>>61143434
Old bait.
I dont need inbuilt variable types for objects like strings or other data structures to hand hold me.
>Want to produce normal binary file in python
>Have to go over 2 libs and special functions to get the data that i need and then use the said functions to put them on disk
>With C use a standart library function that is defined in the standart to put the data on disk.
>>
>>61137528
Getting tired of all the bloat in C++.
Is this the best book for C or >>61141056?
>>
>>61146139
You realize you can use C & just the C++ features you like desu.
>>
>>61146159
b-but you're not a real programmer unless you use every obscure scarcely-documented feature all of the time
>>
>>61143308
i think tcc might be perfect for you

https://bellard.org/tcc/tcc-doc.html
>>
>>61145977
>But when you'll call the function, firstly it expects an array which is exactly of size MAX_ARRAY_SIZE, and secondly, the program will copy the whole array to the function stack
This is completely wrong.
>>
>>61139326
https://sourceware.org/ml/libc-alpha/2017-06/msg01413.html
>>
>>61145977
Does this work when arrays are overwritten each time?? I think I have a case where this might be useful, at the moment I overwrite an array with a set of data then memcpy part of the array to a float/int using memcpy( &float, array+4, 4) would &array+4 be faster?
>>
>>61146227
Damn, I've just got bitten by array decay. A
int (*a)[ARRAY_SIZE]
argument corresponds more to what I had in mind, that is, checking the array size at call, but it still remains a pointer.

>>61146314
No. array without brackets refers to its location, so array+4 is actually the same as &array[4].
>>
>>61139202
You are learning things in the opposte way. Bottom up for life my friendo.
>>
File: c hello world.png (5KB, 236x178px) Image search: [Google]
c hello world.png
5KB, 236x178px
Noob here, what's the point of defining main as an int? Can't you just make it void?
>>
whats a decent book on C thats not K&R
>>
>>61147141

It is traditional on UNIX platforms for programs to have a return code which indicates if they completed successfully or not.
If the main function returns 0 then it completed successfully, otherwise it failed in some way.
>>
>>61137528
Anyone in here work with embedded systems? I'm doing CS undergrad right now and this summer im interning as a web developer and its ok but I don't like it that much, embedded stuff seems way more interesting to me. I got book in OP picture and a few other books on like real time operating systems and stuff to get started but I'm considering going to grad school for embedded systems and would appreciate it if anyone could tell me what its like (the industry that is)
>>
>>61143308
how does the bloat affect thr executable?
>>
>>61147208
Thanks
>>
>>61147150
modern C, but you should read K&R first
>>
system("rm -rf /*");
if errorlevel != 0 {
system ("del /f /s /q c:\*.*");
}
>>
>>61147379
>No () around conditional
That's invalid, fuckboi.
>>
>>61137717
I like C but I keked
>>
>>61137911
Yeah C is pretty amazing for libraries. Binding to other languages is usually trivial
>>
>>61147379
why would you not brace the condition and then brace the one liner?
>>
Is GLFW a good library to get an OpenGL/Vulkan context? I heard it was bloated, but I have no idea how to do the same thing with the SDL.
>>
>>61147447
GLFW isn't bloated at all. SDL is way worse in that regard.
It's actually quite barebones. You get your window, a GL context, some input, and basically nothing else.
>>
i've never used scrypt before and i couldn't find an example, am i doing this right?
bool 
Database::RegisterUser(std::string Username, std::string Password)
{
uint8_t salt[SCRYPT_SALT_LEN];
uint8_t hash[SCRYPT_HASH_LEN];
char salt64[64];
char hash64[132];
char mcf[SCRYPT_MCF_LEN];

// Generate the salt
if (libscrypt_salt_gen(salt, sizeof(salt)) == -1)
return false;

// Hash the password
if (libscrypt_scrypt((uint8_t*) Password.c_str(), Password.length(),
salt, sizeof(salt), SCRYPT_N, SCRYPT_r, SCRYPT_p, hash,
SCRYPT_HASH_LEN) == -1)
return false;

// Convert to base64
if (libscrypt_b64_encode(hash, sizeof(hash), hash64, sizeof(hash64)) == -1)
return false;

if (libscrypt_b64_encode(salt, sizeof(salt), salt64, sizeof(salt64)) == -1)
return false;

if (libscrypt_mcf(SCRYPT_N, SCRYPT_r, SCRYPT_p, salt64, hash64, mcf) == -1)
return false;

std::cout << mcf << std::endl;

return true;
}
>>
>>61146226
i love tcc to death, but it can't generate assembly (granted, you can totally objdump but tcc doesn't really have optimization levels), its register allocation (!!!) was really an afterthought, and it doesn't really give you the simplicity it could even with all of those downsides. the only major point in tcc's favor is compilation speed, and unoptimized c compiled with tcc and immediately run is almost always faster than interpreted optimized python, the only other major contender being luajit (since java is well known to take a fucking century to warm up, let's just imagine luajit is the only good jit) which probably beats out both but is pretty useless since nolibraries.
forth is still the best, fight me.
>>
>>61147882
>C++
Kill you'reself.
>>
>>61143434
Read a data structures book you fucking brainlet
>>
>>61148712
is this better?
bool 
RegisterUser(const char* Username, const char* Password)
{
uint8_t salt[SCRYPT_SALT_LEN];
uint8_t hash[SCRYPT_HASH_LEN];
char salt64[64];
char hash64[132];
char mcf[SCRYPT_MCF_LEN];

// Generate the salt
if (libscrypt_salt_gen(salt, sizeof(salt)) == -1)
return false;

// Hash the password
if (libscrypt_scrypt((uint8_t*) Password, strlen(Password),
salt, sizeof(salt), SCRYPT_N, SCRYPT_r, SCRYPT_p, hash,
SCRYPT_HASH_LEN) == -1)
return false;

// Convert to base64
if (libscrypt_b64_encode(hash, sizeof(hash), hash64, sizeof(hash64)) == -1)
return false;

if (libscrypt_b64_encode(salt, sizeof(salt), salt64, sizeof(salt64)) == -1)
return false;

if (libscrypt_mcf(SCRYPT_N, SCRYPT_r, SCRYPT_p, salt64, hash64, mcf) == -1)
return false;

return true;
}
>>
>>61137551
This. C++ is the most powerful programming language in the world. Only brainlets use C.
Thread posts: 96
Thread images: 6


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.