[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]

/dpt/ - Daily Programming Thread

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: 342
Thread images: 33

File: 666.png (26KB, 480x280px) Image search: [Google]
666.png
26KB, 480x280px
What are you working on, /g/?

Old thread: >>58820533
>>
I love you guys.
>>
I have a little snippet I took from a bigger program
#include <iostream>

int main(){
int a;
double b, c;
std::cin >> b >> c >> a;
std::cout << a << b << c << std::endl;
return 0;
}


this code, when running in linux like
echo "1 2 3" | ./test


works, but on windows, the same command doesn't work (and gives some random numbers). What's happening?
>>
>>58826877
D
>>
Who /web/ here?
>>
File: 2ShootDiary3of40694.png (29KB, 640x400px) Image search: [Google]
2ShootDiary3of40694.png
29KB, 640x400px
>>58826923
It's not gay to love guys, is it?
>>
so, i have this project structure on windows
my_program.cpp

/library
- apv32.dll
- apv32.lib
- apv++32.dll
- apv++2.dll
- lib32.dll
- LIB32.dll
- ap.h
- apv.h
- apv2.h


how do i compile with the "my_program.cpp" with the contents of the folder library?

i did
g++ my_program.cpp -I library/

to include all the files in the library folder

but doesn't work

tl;dr how to include folders in the compilation of c++ programs on windows
>>
>>58826889
how 2 do that?
function = no state and definite output?
>>
>>58826951
I do like
g++ -o test.exe test.cpp -I "C:\includes\moreincludes"
>>
>>58826947
Not if you're a girl, no.
>>
>>58826924
You didn't give a 'a' value
>>
>>58826947
>>58826971
>tfw no trap gf to love tenderly while programming together and exchanging saliva
>>
>>58826993
nope, the value is given via cin. Like I said, it works correctly in linux (or at least it doesn't yield a bad answer), but not in windows with the same command
>>
>>58826993
>a 'a'
'a' a
>>
>>58826951
Keep headers separate from libraries
Include the headers directory with -I
Include the libraries directory with -L
>>
>>58827005
Yeah I see that now. Weird. Maybe it Microsoft's compiler reads the variables sequentially
>>
why is everyone here a noob at programming?
>>
>>58826923
Go to bed, wino. If you don't you'll just feel worst tomorrow.
>>
>>58827027
We have plenty of people here who know their shit
>>
>>58827039
I haven't seen one decent project here by any of the posters
>>
>>58827048
hello newfag
>>
>>58827048
That happens if you've only been here one day
>>
>>58827056
>>58827065
go ahead name one
>>
>>58827022
well, it wasn't so hard, but I don't have an explanation: removing those "" works on windows, so the command would be:
echo 1 2 3 | test.exe

command line in windows sucks hard
>>
>>58827077
That guy who's written a 4chan browser in 20,000 lines of BASIC.
>>
>>58827135
Where? post it I want to believee
>>
>>58827143
It's not mine, you derp. Who in their right mind would write 20k lines of BASIC?
>>
>>58827077
One guy's working on a VM, it's either in the last thread or the one before it
>>
>>58827048
Most people here pick functional languages in the hope to become better coders. When they realize that it's not the magic recipe they begin doing what you are doing right now.
>>
>>58827077
This guy's writing and assembler: >>58822382
>>
>>58827165
I am an object oriented programmer since I know the best way to manage medium to large programmers is by OOP
>>
>>58827173
At what weight does a medium programmer become a large programmer?
>>
File: b.png (1KB, 439x265px) Image search: [Google]
b.png
1KB, 439x265px
>>58827014
do the .dll files have to be in the path of the system in order for me to compile with the libraries?

i tried what you said
g++ my_program.cpp -o out.exe -I heades -L library


and still no luck
>>
>>58827185
sorry I meant medium to large projects

>>58827168
finally a decent project that is pretty cool actually
>>
What are people making that isn't web based these days besides video games and mobile apps?
>>
>>58827214
compilers

programming languages

kernel drivers
>>
There aren't enough rust programmers here
>>
>>58827048
I'm working in a cool project, but if I post it here I will stop being anonymous and don't want to be found that I browse 4chan for its strong relation with /b/
>>
>>58827214
i'm writing lightweight encryption software for shits and giggles
>>
>>58827192
>heades
>>
>>58827233
what kind of project is it? What is so bad about that? What would happen?
>>
>>58827192
Sorry, -L should point directly to the library, not its containing folder
http://www.cprogramming.com/tutorial/shared-libraries-linux-gcc.html
Google it if you're still confused, it'll be good for you
>>
File: 1465531407355.jpg (11KB, 184x184px) Image search: [Google]
1465531407355.jpg
11KB, 184x184px
>>58827185
300 lbs.
>>
Trying to make a 4chan board parser and am currently using the 4Chan API (here: https://github.com/4chan/4chan-API)

How do I even begin to organize the data?

Here's what I have so far:
    import json
from urllib2 import urlopen
url = "https://a.4cdn.org/g/catalog.json"
jsonurl = urlopen(url)
text = json.loads(jsonurl.read())


(Sort of related question, what types of libraries are available for JSON for C/C++? I'm thinking of making this a larger scale project and feel like those C++ would be better than python)
>>
>>58827263
from json import dumps

dumps(text, indent=4)

>>
>>58827263
You have successfully written (imported) a parser.

What do you want to do with the data.
>>
File: 1.jpg (57KB, 445x459px) Image search: [Google]
1.jpg
57KB, 445x459px
i'm on windows

on my mingw folder i have
glu32.dll
glu32.lib
glut32.dll
glut32.lib
opengl32.dll
OPENGL32.lib

yet when i do
g++ opengl_program.cpp -lglu32 -lopengl32 -lglut32


it outputs
....../mingw32/bin/ld.exe: cannot find -lglut32


how the fuck it cannot find glut32, but the other libraries i included finds them?
>>
>>58827383
fuk lads im leaving the board forever.

It was four spaces right?
//test
//test
>>
>>58827422
[ code ] tags, look into the pinned thread on the first page.
Wakabamark-less boards suck indeed.
>>
>>58826951

g++ -I ./library -L ./library


You will still have to link against the dlls with the -l flags (that's a lower case L). When the filename begins with "lib" as in libSDL2.dll, you'd use it like -lSDL. Otherwise, you'd use it like -l:apv32.dll

By the way, if those DLLs were compiled with MSVC++, you're going to have issues trying to link them in with g++. They use different name mangling schemes.
>>
>>58827296

For now, I just want to get used to parsing JSON with Python. Something I'd want to do is to pass in a string argument and displays the threads with that contains the string as a subject (ie, searching for "dpt").

Eventually, i want to make a 4chan desktop browser (similar to clover for android)
>>
>>58826877
Adding FLIF support to my taggable image viewer Ivy. It's mostly done, I just need to do some testing and some other busywork before I can call it complete.
>>
Say you want to get all digits from a string, then add them back in the correct position.
How would you do that without arrays?
>>
>>58827252

You are reading this tutorial wrong. In the tutorial, libfoo.so is located at /home/username/foo/libfoo.so. Therefore, you must use -L/home/username/foo (the folder containing the library) and -lfoo (the library itself).
>>
>>58827495
You *have* parsed the JSON with that code. What you've called 'text' is the Python object that contains all the data.

Do this: >>58827291
And figure out where your thread names are within the object.
>>
>>58827527
you again?

post input and output examples, so i can know what the fuck you talking about
>>
>>58827192
>HEADES
>>
>>58827478
thanks! it works now
>>
>>58827562
forgot an r

>HEADE-->r<--S
>>
>>58827527
i'd do something like
do {
if (isdigit(str[n])
num = (num << 4) + str[n] - '0';
} while (n--);
>>
>>58826877
Simple shit for an assignment - got full marks because we were only supposed to be marked for changing the colour of a div with Javascript.


<button id="bgBtn" class="myButtons">Change background</button>
<button id="moveBoxBtn" class="myButtons">Move box</button>
<button id="changeParaBtn" class="myButtons">Change content of paragraph</button>

<script>
var box = document.getElementById("box");
var bgBtn = document.getElementById("bgBtn");
var moveBoxBtn = document.getElementById("moveBoxBtn");
var changeParaBtn = document.getElementById("changeParaBtn");

(function(){
window.alert("JavaScript is in use!");
}());

bgBtn.addEventListener("click", changeBackground, false);
function changeBackground(){
if (box.style.backgroundColor === "red"){
box.style.backgroundColor = "blue";
}
else {
box.style.backgroundColor = "red";
}
}
moveBoxBtn.addEventListener("click", moveBox, false);
function moveBox(){
if (box.style.left === "0px"){
box.style.left = "50px";
box.style.top = "50px";
}
else{
box.style.left = "0px";
box.style.top = "0px";
}
}
</script>

.

My problem is that clicking on "Move box" button does nothing for the first click then proceeds to work as intended.
Any reason why?
>>
>>58827547
"Th1s 1s a t3st str12ng" as input, without numbers you should get "Th s s a t st str ng"
I get that you can just make it replace the numbers in the string with " " and save its position. However, when I try to put them back in order I get an out of bounds exception.
>>
>>58827573

No problem, Anon.
>>
>>58827601
what language?
>>
>>58827625
C#
>>
>>58827600
Full thing listed here - any pointers would be greatly appreciated.

http://pastebin.com/PdtNdnVA
>>
>>58827625
Also note that the string for numbers and position are both the same length.
Position: "1 6 12 22"
Number: "3 3 8 5 ";
>>
>>58827633
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace tonguemyanus
{
public class Program
{
public static void Main(string[] args)
{
string s = "Th1s 1s a t3st str12ng";
string s1= Regex.Replace(s,"[^A-Za-z_]"," ");
System.Console.WriteLine(s1);
}
}
}

output

Th s  s a t st str  ng
>>
>>58827600
1. Use the debugger.
2. Inspect box.style.left before you click the button for the first time.
3. ?????
>>
>>58827744
Main problem is getting the numbers back into the string at the correct position
>>
>>58827744
Some people, when confronted with a problem, think “I know, I'll use regular expressions.” Now they have two problems.
>>
>>58827747
4th step is profit thanks
>>
>>58827756
>problem
you just have to save its position, for example in a hash map or something
>>
>>58827600
because the very original box needs to be positioned properly in the top left corner
>>
File: Capture.png (10KB, 210x65px) Image search: [Google]
Capture.png
10KB, 210x65px
>>58827756

save the position in a tuple (or some other data structure)

 List<Tuple<int, char>> nums = new List<Tuple<int, char>>();

var index = 0;
var output = "";

input.ToList().ForEach(c =>
{
if (char.IsDigit(c))
{
nums.Add(new Tuple<int, char>(index, c));
output += " ";
}
else
output += c;
index++;
});


then iterate through the tuples and insert the numbers back in

            nums.ForEach(n =>
{
output = output.Substring(0, n.Item1) + n.Item2 + output.Substring(n.Item1 + 1);
});
>>
>>58827805
Here's the CSS in full.


<style>
#container{
width: 500px;
height: 300px;
border: 2px solid black;
position: relative;
background-color: #C9FFA2;

}
#box{

position: absolute;
width: 50px;
height: 50px;
background-color: blue;
left: 0px;
top: 0px;
}

.myButtons {
background-color: #252781;
border: none;
color: white;
padding: 10px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
border-radius: 6px;
}
.myButtons:hover { <!-- :hover selector to change the style of the button when you move the mouse over it. -->
background-color: #008CBA;
}
</style>

>>
>>58827870
Hey i got a question

is this a college assignment or other thing?

i was looking to learn javascript and this looks neat to learn
>>
>>58827214
I hope that the browser of those "web app devs" explodes, web apps are a threat to humanity and fellow programmers.
>>
>>58827541
Alright... So the JSON is stored as a dictionary of unicode characters (or is it a list of dictionaries of unicode characters?), but I'm having trouble thinking of how to iterate through each "bracket" object and print out the subjects of each thread (or at least a tutorial where I can practice this)
>>
>>58827798
>>58827841
I did, see >>58827659
The problem is that I get an out of bounds exception when I go through the string.
Should I go through the string of positions, check for digits, convert them and add the corresponding number to the string?
Position: "1 55"
Number: "4 7 "

Check if the number on position i in position is two digits, multiply the first by ten and add the second, use that as the index for the string, and use i on numbers to get the number on that index.

Is that correct, if you know what I'm trying to say?
>>
File: Capture.png (3KB, 283x108px) Image search: [Google]
Capture.png
3KB, 283x108px
>>58827600
box.style.left is not "0px" by default
>>
>>58826877

`` javascript

console.log="100";

``
>>
>>58827909
It's an assignment (THAT WAS ALREADY GRADED THIS IS EXTRA). I'm currently in college for this stuff, yeah.
>>
>>58827369
The glu32 and glut32 libraries might conflict with each other.
>>
test
>>
making flask web app. untested code to yank a post with comments and comments of comments.


def loadPost(post_id):
db = get_db()
# retrieve post
cur = db.execute('SELECT * FROM posts where posts.id=?', [post_id])
post = cur.fetchone()

# get comments
cur = db.execute('SELECT * FROM comments where comments.post_id=? ORDER BY posts.date DESC LIMIT 5', [post_id])
postComments = cur.fetchall()

# store comments [(comment, [comments])]
comments = []

# get comments of comments
for comment in postComments:
cur = db.execute('SELECT * FROM comments where comments.comment_id=? ORDER BY posts.date DESC LIMIT 5', [post_id])
commentsOfComment = cur.fetchall()
commentRepo.append((comment, commentsOfComment))

cur.close()

return render_template('index.html', post=post, comments=comments)

>>
>>58827943
Thanks! Just added it in. Great help, guys.

Again, you didn't give me marks for an assignment it was an already-graded lab quiz for the colour change.


box.style.left="0px";
box.style.top="0px";
moveBoxBtn.addEventListener("click", moveBox, false);
function moveBox(){
if (box.style.left === "0px"){
box.style.left = "50px";
box.style.top = "50px";
}
else{
box.style.left = "0px";
box.style.top = "0px";
}
}

>>
>>58827985
I have done all that web dev stuff before it's all about experimenting
>>
>>58827937
ah I missed that. Split your strings into arrays/lists and then work from there

var positions = Position.Split(' ').ToList();
var numbers = Numbers.Split(' ').ToList();

for(int i = 0; i < positions.Length; i++) {
//logic to insert number[i] into position position[i] of the output
}
>>
File: poointheloo.jpg (136KB, 1057x918px) Image search: [Google]
poointheloo.jpg
136KB, 1057x918px
guys I seriously thought it was only a dumb meme.
>>
>>58828019
ifelifififelifelifelififelifififelififif
>>
>>58828010
I'm sorry, if this was done with arrays, it wwould be easier, but the professor wants it without. Is my logic correct though?
>>
>>58828019
i, ii, iii, n = '', '', '', n.split(" ")[0]

i feel like this shouldn't be allowed
>>
>>58828019
i see nothing wrong with this code
>>
>>58828076
Take a closer look Pajeet
>>
>>58828086
still don't see it
>>
>>58828055
You mentioned parsing the number in position and then adding that back to the string, but I think you want to parse position AND number then add the number to the correct position. Otherwise yea, your logic makes sense.


It might be easier to just look through the string until you hit a space, then int.Parse() whatever you get rather than reconstructing the numbers yourself. That way you can handle positions of any size rather than <= 99
>>
File: 1.png (21KB, 170x254px) Image search: [Google]
1.png
21KB, 170x254px
I'm going to start using Windows more, and want to use gcc. Any reason why I shouldn't use MinGW over cygwin?
>>
>>58828157
Why not Linux in a VM?
>>
>>58828137
Through the position string? Does it parse correctly for multiple numbers?
So I check if it's either one, two or more numbers, then parse the either, one, two or more? I feel like I'm misunderstanding you.
>>
>>58827120
Try using Cygwin or MSYS2 on Windows. You can basically run programs like you would in Linux after you compile them and they also can work natively on Windows
>>
File: imperial_bytes.png (76KB, 1031x291px) Image search: [Google]
imperial_bytes.png
76KB, 1031x291px
Just patched "ls" in GNU coreutils in honer of Trump.
>>
>>58828197
I don't know much about VMs, and seems like it'd be overkill. But I don't know.
>>
>>58828076
>>58828090

Problems:

1. Using a hash table/dictinoary where the keys are integers, starting with 0 in linear index order to 9, with no keys skipped. This is clearly a case for an array.

2. i, ii, and iii are not very descriptive names. If one wanted to use throwaway names, a single letter for each would have been acceptable, such as i,j,k. Alternatively, a single variable that is an array storing the parameters in order would also have been acceptable, as Python allows parameters to be applied from an array (i.e. format(*ary))

3. The entire function really needs to be restructured to not be a giant nested if/else chain. It's difficult to read, and perhaps difficult to maintain.

4. One must beg the question why the argument to this function is a string representation of a number
>>
>>58828157

Definitely use MinGW-w64 over Cygwin. Any application linked against cygwin1.dll automatically becomes GPL.

>>58828197

To target Windows on Windows, perhaps?
>>
>>58828314

Any reason you aren't using cupbyte, pintbyte, quartbyte, and gallonbyte? Data storage can be more easily thought of as volume than distance.
>>
class SomeClass{
public:
SomeClass();
private:
int x;
}

class SomeOtherClass{
..standard stuff
SomeClass* SCPTR;

}


SomeOtherClass.cpp

SomeOtherClass::SomeOtherClass(){
?...SCPTR = new SomeClass();...?
}

I want a ptr to someclass, how do I do that? do I have to return the address of "this" in the SomeClass constructor or something?
>>
>>58827120
Maybe because echo "1 2 3" on windows literally produces "1 2 3" instead of 1 2 3. kek
>>
Rate my functional and arithmetic-free JavaScript FizzBuzz, /g/

Array(100)
.fill('')
.map(
(
(fizzbuzzer) =>
(
(fizzer, buzzer) =>
fizzer() + buzzer()
)
.apply(null, fizzbuzzer)
)
.bind(null,
(
(func) =>
[ func.bind(null, ['', '', 'Fizz']), func.bind(null, ['', '', '', '', 'Buzz']) ]
)
(
(list) =>
[ list[0], list.push(list.shift()) ][0]
)
)
)
.map(
(
(counter, element) =>
[element ? element : counter.length, counter.push(true)][0]
)
.bind(null,
[true]
)
)
.forEach(
(element) =>
console.log(element)
);
>>
>>58828240
int.Parse will turn any string into a number (assuming the string is a number). Here's some pseudo-code of what I think your logic should be

var Position = "1 55"; //variable length number
var Number = "4 7" //number is always 1 char long 0-9
var index = 0; //you will need to track this separately since each position could have a different length in digits
var position_string = ""; //keep track of the last numbers in the position string until a space is hit


Number = Number.Replace(" ",""); //remove spaces from Number string, they only complicate things

for(int i = 0; i < Position.Length; i++)
{
if (Position[i] is a digit character)
position_string += Position[i]
else //if it's a space
{
//parse the position number
pos = int.Parse(position_string)

//get the number at index
num = Number[index] // multiply by 2 to

output = output.Substring(0, pos) + num. + output.Substring(pos + 1) //place the num into the position in your output

position_string = ""; //reset
index++; //increment index
}

}
>>
>>58828490
oops, forget the "// multiply by 2" comment. That part is avoided by removing spaces from Number. If you don't, you need to increment the index by 2 instead to avoid picking up the spaces.

Sorry if none of this makes sense, I suck at explaining things
>>
>>58828454
i did this
SomeOtherClass::SomeOtherClass(){
PTR = & SomeClass();
}


but when I call a function using that pointer like
PTR->someFunction();

my code crashes?
>>
In C++, is there a way to split up int variables so that I use individual digits for stuff? Got a homework assignment that wants me to simulate machine language programming. The way it does this is having these four digit codes where the first two digits represent an operation (adding, subtracting, branching, etc.) and the last two represent placing in memory. I then store the code into an array which is supposed to be simulated memory. I'm just kinda confused as to how I can split ints the way the book wants to. I know that I gotta use pointers but that's still kind've a fuzzy concept for me.
>>
>>58828521
use % 10
% 100
% 1000
and so on, to get individual base-10 digits from an int
>>
>>58828556
Or do it in a loop

int number = 12345;

while (number > 0)
{
printf("%d\n", number % 10);
number /= 10;
}
>>
>>58828454

This seems to work for me:

// SomeClass
class A {
int x;
public:
A();
};

A::A() : x(0) { }

// SomeOtherClass
class B {
A *aptr;
public:
B();
~B();
};

B::B() { aptr = new A(); }
B::~B() { delete aptr; }
>>
>>58828486
What the actual hell?
>>
File: vomit.jpg (90KB, 650x650px) Image search: [Google]
vomit.jpg
90KB, 650x650px
>>58828588
>>
>>58828588
i forgot the new keyword, now it works. thank you.
>>
>>58828605

It's example code. It doesn't need to look perfect; it just needs to explain what's going on in the simplest terms.
>>
>>58828653
I was just disgusted by C++'s syntax, and how something that hideous is considered proper C++.
>>
In Haskell, how can I check if a string being passed in is a bank of other strings?
I'm trying to pass in an array of strings, and if certain strings show up, to do a certain action. So
function1 :: [String] -> [String]
>>
>>58828591
Intimidated, you imperative pleb?
>>
>>58828486
what does it mean for a string to be a bank of other strings?
>>
>>58827077
that guy that is writing a world-destroying AGI
>tfw anon won't be a pet servant of the glorious AGI
>>
File: terrified_lane.jpg (326KB, 654x474px) Image search: [Google]
terrified_lane.jpg
326KB, 654x474px
>>58828374
>automatically becomes GPL
>>
>>58828756
the GPL is a virus that must be destroyed.
>>
>>58828747
passing in a list of strings, if a certain string shows up, I want to do something to it
>>
>>58828772
>if a certain string shows up, I want to do something to it
Why? What did it ever do to you?
>>
File: 1362765593187.jpg (62KB, 480x640px) Image search: [Google]
1362765593187.jpg
62KB, 480x640px
>>58828765
Shut the fuck up young bitch
GPL will prevail
>>
>>58827527
>>58827601
You still here?

What are the actual assignment requirements?

Just remove the numbers and put 'em back in?
>>
>>58828772
https://www.haskell.org/hoogle/?hoogle=a+-%3E+%5Ba%5D+-%3E+Bool
>>
>>58828789
https://github.com/blog/1964-open-source-license-usage-on-github-com
>>
>>58828789
fuck you stallman zlib is better
>>
>>58828789
the GPL destroys the fundamental freedom to have closed source software, hence any software written using the GPL is not free
>>
We should team up with /diy/ and make a computer + OS
>>
File: 1365627691197.png (222KB, 618x367px) Image search: [Google]
1365627691197.png
222KB, 618x367px
>>58828852
This "freedom" is nothing but an illusion
Don't be fooled by it
>>
File: anal beads.png (22KB, 514x390px) Image search: [Google]
anal beads.png
22KB, 514x390px
Posting this in case that C# anon comes back looking for his homework.

Ugly, but shows some of the approaches he could take for what he's trying to do:

static void Main(string[] args)
{
var input = "Th1s 1s a t3st str12ng";
var numbersWithPositions = new List<Tuple<char, int>>();

numbersWithPositions.AddRange(
input.Select((x, i) => char.IsNumber(x) ? new Tuple<char, int>(x, i) : null)
.Where(x => x != null));

numbersWithPositions.ForEach(x => WriteLine($"Number {x.Item1} is at position {x.Item2}."));
WriteLine($"The sum of all the numbers is {numbersWithPositions.Select(x => x.Item1 - '0').Sum()}");

input = Regex.Replace(input, "[^A-Za-z_]", " ");

WriteLine(input);

var ayylmao = new StringBuilder(input);
numbersWithPositions.ForEach(x => ayylmao[x.Item2] = x.Item1);

input = ayylmao.ToString();

WriteLine(input);

WriteLine("Press any key to exit...");
ReadKey();
}
>>
Dear /g/,

I have fell in love with Rust, everyday I go and read the rust subreddit and search 'rust' on /dpt/'s... Please help...

I can't take it anymore... where is the cure?
>>
>>58828932
Rust is a nice systems programming language. It's the better C++, however it's still hard to adopt, even for a C++ dev.

Golang is also a nice language
>>
>>58828977
You're not helping goddammit
>>
>>58828932
>
https://github.com/rust-lang/rust/issues/38869

hehe
>>
>>58828772
write a function that changes a single string how you want:

change:: String -> String
change a = case a of
"test" => "test1"
"foo" => "bar"
x => x

Then map it to your list
 function1 :: [String] -> [String]
function1 strings = map change strings
>>
>>58829029
>Being too autistic to understand a satire
>>
>>58828905
freedom:
1. the power or right to act, speak, or think as one wants without hindrance or restraint.
2. unrestricted use of something.

The GPL is a violation of fundamental freedom because it restricts the use of software. Software written using the GPL is fundamentally un-free.
>>
>>58829112
Linux has a GPL license
>>
>>58829112
>it restricts the use of software.
stealing* of software
>>
>>58828556
>>58828578
This seems a little messier than what I was expecting, but thanks! Exactly what I needed.
>>
>>58829112
That's like saying you aren't actually free because you can't own slaves.
>>
good programmer here I would like to give back to this good community

post any assignments or questions about programming and I will help you with it
>>
>>58828910
Jesus, this is why C is the best
#include <stdio.h>
#include <ctype.h>

void print_no_num(const char *str)
{
char *ch = NULL;

if (!str)
{
return NULL;
}

for (ch = str; *ch != '\0'; ch++)
{
if (!isdigit(*ch))
{
putchar(*ch);
}
}
}

int main(void)
{
const char Muh_Str[] = "H31lo W0rld";
char *ch = NULL;
int sum = 0;

for (ch = Muh_Str; *ch != '\0'; ch++)
{
if (isdigit(*ch))
{
printf("%c is at position %d\n", *ch, ch - Muh_Str);
sum += *ch - '0';
}
}

printf("The sum is %d\n", sum);
printf("This is the string without numbers: ");
print_no_num(Muh_Str);
printf("\n");
printf("This is the original string: %s\n", Muh_Str);

return 0;
}
>>
>>58829355
question: how many thigh-highs do you own?
>>
>>58829386
programming questions only please
>>
>>58829411
how might I calculate the number of thigh-highs you own using recursion?
>>
>>58829446
solve for the factorial of 4 to find the answer to such a question
>>
>>58829365
You failed to read the restraints put forth by that anon.

No arrays, and you must remove the numeric characters from the input string and add them back again.

Also, one could write code almost identical to what you've written here in C#.
>>
>>58828635

Don't forget the destructor and the delete keyword, or you'll leak memory.

>>58828756

That's what happens when you don't have a linking exception.
>>
>>58829471
>r you'll leak memory.
unused RAM is wasted RAM
>>
>>58829365
>Muh_Str
Okay I keked
>>
File: 1482561929832.png (86KB, 325x243px) Image search: [Google]
1482561929832.png
86KB, 325x243px
>>58829507
>That bracketing
Use proper conventions for the language, jesus
>>
>>58829463
>No arrays
I didn't use any though except for
Muh_Str
because a string, by definition in C, is a null-terminated array of characters.
>>
>>58829529
its much easier to read
at glance, you can tell which code belongs to which block
>>
File: 1482602151807.jpg (63KB, 550x411px) Image search: [Google]
1482602151807.jpg
63KB, 550x411px
Is OOP really like fitting a square peg into a round hole?
>>
>>58829504
Is this a dank meme? Cause you got a LOL outta me.
>>
>>58829507
vim theme?
>>
>>58829529
There's literally nothing wrong with that, retard. Kill yourself.
>>
>>58829561
solarized light
>>
is anybody familiar with qt? it's really slow, how do i make it faster?
>>
>>58829507
>
    case 1: ret = 2;

fucking fallthroughs
>>
>>58828730
If by 'bank' you mean 'list', then use elem:
elem 5 [1..10] -- evaluates to True
elem 15 [1..10] -- evaluates to False


I don't understand the second part of your post. Example input and output?
>>
>>58829591
lmao nvm, same thing as yesterday when i asked this question about vs. it has a release and a debug mode and for some reason, it's super fucking slow in debug mode.
>>
>>58829603
what does that mean
>>
>>58829507
>main method not at the top
shit code
>>
>>58829628
it means you're fucking retarded. learn to program before customizing VIM, kid
>>
>>58829507
you need break statements in your switch statement or it will go all way through not stopping to the last one ending in always returning 1
>>
>>58826877
I need help, /g/. In one of my classes, I need to write a program that tokenizes strings. Easy enough under normal circumstances, but the function prototype MUST be
int makearg(char *s, char ***args); 
and I don't see how I'm supposed to accomplish this task while utilizing the entrance to pointer hell being exhibited. Any help?
I'm using C++, in case that isn't obvious.
>>
>>58829655
you're really learning the important stuff
>>
>>58829552
It's like fitting a square peg into a round hole that doesn't exist
>>
>>58829655
what the fuck is it supposed to do? char *** is a 2d array of strings, why does it need to be 2d? If it is supposed to be
int makearg(char * s, char ** args)
then it is easy
>>
>>58829634
>>58829643
>>58829529
thanks for telling me exactly wha'ts wrong with my code, I definitely learned from being berated over inane stuff
>>
>>58829552
In french, the acronym of OOP is POO.
>>
>>58829655
Email your professor and ask if he's having a giggle
>>
>>58829706
I did, anon.

He said to go fuck myself and if i thought that college was a place to learn things to drop out right now.
>>
>>58829603
oh sorry, i had it as
case 1 : return 2;
...

but I changed it, sorry
>>
>>58829461
that's a lot of thigh-highs qt
>>
how many women have you guys picked up by learning programming?
>>
>>58829695
I said it falls through, how did I not answer your fucking retarded question? Sorry I didn't literally write out proper code for your stupid ass. If I give you the name of the error I expect you to be able to google and figure out more detailed information.

Sorry you're so fucking pajeet that you cannot even google.
>>
File: 1.png (215KB, 1218x703px) Image search: [Google]
1.png
215KB, 1218x703px
>>58829748
>>
>>58829748
>3D
0
>2D
infinite

>>58829774
now this is reddit-tier
>>
>>58829685
>what the fuck is it supposed to do
I'm entirely not sure. The example given is just that it tokenizes the string "ls -l file" which isn't exactly helpful. The task itself isn't particularly difficult, but my professor was very explicit in that the prototype is correct and that we can't change it.
I'm currently trying to figure out a way that I can even make it work the way he seems to want it to.
>>
>>58829774
awww yeah Java plus 1 for women
>>
>>58829655
You can send the address of a char ** and then modify it value in your function to a new array of tokens. This way you can return the number of token with the int?
>>
>>58829774
i hope this is from reddit
>>
>>58829811
there is literally no way to tokenize into a char *** (other than ignoring the char *** and treating it as a char **)

It is either a typo, you misunderstanding the problem entirely, or your professor is an idiot
>>
what advice would you guys give to beginner programmers who want to become good?
>>
guys I wrote this algo for an Othello game puzzle but when I try to submit it I get the error

STDERR:
Traceback:
in
in reversi_row
UnboundLocalError: local variable 'i' referenced before assignment

def alt():
while (True):
yield '*'
yield 'O'
def reversi_row(moves):
player = alt()
board = ['.']*10
for i in [x+1 for x in moves]:
index, drct, both = 1, 0, 0
change = []
board[i] = next(player)
crrntplayer = board[i]
if (board[i+index]!=crrntplayer and board[i+index]!='.'): drct=1; both+=1
if (board[i-index]!=crrntplayer and board[i-index]!='.'): drct=-1; index=-1; both+=1
while(True):
while(board[i+index]!=crrntplayer and board[i+index]!='.'):
change.append(i + index)
index += drct
if board[i+index]==crrntplayer:
for i in change:
board[i] = crrntplayer
both += -1
if both>0:
drct *= -1; index*=-1; change = []; continue
else: break
return ''.join(board[1:-1:])


do you have any idea?
It works perfectly fine in my PyCharm
>>
>>58829873
>python
I'm so, so sorry anon
>>
>>58829873
>while(board[i+index]!=crrntplayer and board[i+index]!='.'):
>i+index
where does i come from here ?

its outside the for loop, so it doesn't know where its comming from
>>
>>58829873
you didn't initialize i properly
>>
Newfag 2nd semester programmer here. Making a hangman game in C++ for a class assignment to practice 2d arrays and looping. Please tell me how to not suck /g/ Senpai.
>>
>>58829927
dragon dildos
>>
>>58829927
seems like that should be done in the first semester
>>
File: 7772.gif (323KB, 245x170px) Image search: [Google]
7772.gif
323KB, 245x170px
>>58829705
>>
>>58829935
/e/pik reply my /b/ro
>>
How, exactly, do you take pictures of your code to post it here?
>>
>>58829748
i think i've only repelled women when i told them i'm a compeng major
>>
>>58829904
>>58829912

ty. looks like I messed up my indentation
>>
>>58829833
Well, I suppose that works. Not how I would have done it, but I don't particularly care if the professor has no reason to complain.
>>58829850
He has it three separate times in the pdf, so it's unlikely to be a typo.
I'm betting on him just being an idiot; his lectures are primarily just him rambling about COBOL and showing a fundamental lack of understanding of Linux.
>>
>>58829705
IN LOO
>>
>>58829956
screenshot?
>>
>>58829956
>>58829956
Typically you just press the print screen key, but there's plenty of programs that will capture your screen for you if print screen is insufficient for whatever reason.
>>
holy shit why is imperative progarmming so tedious
I wanna use lisp but it's not expressive enough.
>>
have you learned your Go today?

https://tour.golang.org
>>
>>58830049
More like No
>>
>>58830031
>I wanna use lisp but it's not expressive enough.
wat
>>
>>58830049
why
>>
>>58829833
>>58829655

If this guy is right (he probably is since that is the only thing that makes sense)

int makearg(char * s, char *** args) {
// store the size of the list of tokens, may need to resize if it grows beyond this
unsigned int size = 10;

// this will be the list of tokens. we will set *args to be this when finishing this function
char ** tokens = malloc(sizeof(*tokens) * size);

// this is the actual number of tokens found, not the size of the list
int num_tokens = 0;

// start_index is the start of each token
unsigned int start_index = 0;

// while we are not at the null terminator keep tokenizing
while (s[start_index] != '\0' && start_index < strlen(s)) {

// finish_index is the last character in the token
unsigned int finish_index = ++start_index;

// keep looking for the end of the token
while (s[finish_index] != '\0' && s[finish_index] != ' ') {
finish_index++;
}

// we now have a token that is within start_index and finish_index

// if we ran out of space in our list we need to resize it
if (num_tokens >= size) {
tokens = realloc(tokens, size * 2);
size *= 2;
}

// we insert a null terminator at the end of the token since finish_index will either already be a null terminator or the space character that we wish to ignore
s[finish_index] = '\0';

// insert the token into the list and update the count of tokens
tokens[num_tokens++] = strdup(s[start_index]);

// update the start_index for finding the next token
start_index = ++finish_index;
}

// set the variable as said before and return the count we got
*args = tokens;
return num_tokens;
}
>>
>Rust
bust
>>
>>58829536
Then implement an immutable string and go from there.
>>
>>58830067
things feel hacky
although I like that you can use state
>>
>>58830090
>bust
nut
>>
>>58830103
CL is hacky, Racket and Scheme are elegant. All three have about as much expressive power as you're likely to find in a programming language.
>>
>>58830067
for example, given any small scale challenge, haskell is found to be more expressive than any lisp
>>
>>58830172
Not him, but I've been interested in lisp and decided CL
Why is it hacky compared to Scheme or Racket?
>>
I enjoy writing and typing a lot which programming language requires the most writing for everything?
>>
>>58830196
java
>>
how do you measure compilation times in windows command line?
>>
>>58830176
For small problems I'd say Haskell has the edge (due largely to its ridiculous Data.List module), but lisps scale better as you layer on the abstraction.

To be honest, it's pretty neck and neck; I use both.

>>58830191
It's ugly as sin: function names are daft, libraries are non-orthogonal, and some of the core semantics just aren't as clean as Scheme (see nil/()/'()/etc). And I still can't get over LISP-2s.
>>
>>58830196
C, the language is so cippled it requires writing the same code over and over.
You have to hack things together (macros, polymorphy)
People say that no features is a feature, but that's just fanaticism (same with those Common Lisp fags that are 3evangelical5me)
>>
What language would be good to write an AI to organize my memes?
>>
>>58830223
>non-orthogonal
>nil/()/'()
expand more on this pls
>lisp-2s
you don't like non-schemes?
>>
>>58830255
lisp
>>
>>58830255
Prolog
>>
rate my code

/**
*
* @author John
*/
public class PathTransition extends Application {

@Override
public void start(Stage primaryStage) {

Pane pane = new Pane();

Rectangle rectangle = new Rectangle(0,0,25,50);
rectangle.setFill(Color.ORANGE);

Circle circle = new Circle(125,100,50);
circle.setFill(Color.WHITE);
circle.setStroke(Color.BLACK);

pane.getChildren().add(circle);
pane.getChildren().add(rectangle);

final PathTransition pt = new PathTransition();
pt.setDuration(Duration.millis(2000));
pt.setPath(circle);
pt.setNode(rectangle);
pt.setOrientation(
PathTransition.OrientationType.ORTHOGONAL_TO_TANGENT);
pt.setCycleCount(Timeline.INDEFINITE);
pt.setAutoReverse(true);
pt.play();



circle.setOnMousePressed(new EventHandler<MouseEvent>() {

@Override
public void handle(MouseEvent event) {
pt.pause();
}
});

circle.setOnMouseReleased(new EventHandler<MouseEvent>() {

@Override
public void handle(MouseEvent event) {
pt.play();
}
});



Scene scene = new Scene(pane, 300, 250);

primaryStage.setTitle("PathTransition");
primaryStage.setScene(scene);
primaryStage.show();
}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}

}

>>
>>58826877
solving captchas for azn moot
>>
>>58830172
>racket
I wanted to try that but so many new concepts.
>contracts
>ports
>quasiquoting
>>
File: hhh.jpg (23KB, 336x377px) Image search: [Google]
hhh.jpg
23KB, 336x377px
>tfw a project is coming together.
>>
>>58830060
why

>>58830076
because it's awesome
>>
>>58830309
>inb4 spaghetti project and you spend the remaining ours refactoring
>>
>>58830265
I don't like LISP-2s.
(map #'square (list 1 2 3 4))
is just noise.

Common Lisp also conflates the false value with the empty list (which are both also 'nil'): this is dumb.

Common Lisp generally has several slightly different ways to do the same thing. It takes the 'everything including the kitchen sink' approach to language design, whereas I like to keep the core language as small as possible and implement new features on top of said language.

That said, if I use LISP, I use SBCL (TM)(C)(R). Request it by name from your local package manager.
>>
>>58830291
Contracts and ports are admirably sane (like most Racket/Scheme design decisions), and quasiquoting is present in all LISPs that I know of.
>>
please tell me there is an algebra trick which lets you make a number 1 but keep its sign. something with dividing by itself and something more?
>>
hey /g/
can you explain to me (cs student and intermediate to shitty programmer) why all you guys seem to talk about is "functional" or "meme" programming languages?

I find them difficult to read & understand. What's the purpose / benefit of them?
>>
>>58830343
I started with CL so I haven't felt Schemes, should I really read SICP
also, the problem I have is that it has new names for stuff
this is why I thought monads where some magical thing but they were just memes
>>58830329
is that it, just that it has multiple ways of doing things
what about CLOS
>>
>>58830385
nothing to understand really all you have to do is know your libraries to program
>>
>>58830402
or actually, a book for CL fags wanting to /scheme/
>>
File: 1486432001345.jpg (28KB, 637x346px) Image search: [Google]
1486432001345.jpg
28KB, 637x346px
So, what's a good alternative to git?

Yet another open source software that's been infected by SJWs. It's like (((they))) want open source to die.
>>
>>58830382
>>58830382

I mean make all negative numbers to -1 and all positive numbers to 1 without using an if statement but with algebra
>>
>>58830402
>is that it, just that it has multiple ways of doing things
Having multiple ways of doing the same thing is pretty much the definition of 'non-orthogonal'; you asked me to expand on it :)

>should I really read SICP
SICP teaches programming, it's not a book with which to learn Scheme.

>this is why I thought monads where some magical thing but they were just memes
I really don't know what you mean by this. Monads are just monoids in the category of endofunctors.
>>
>>58830446
Sicp is a meme book it is outdated and not useful to modern day programming
>>
>>58830382
You literally divide it by itself (unless it's zero).
>>
>>58830429
Divide them by the numbers magnitude
>>
>>58830459
>Sicp is a meme book it is outdated and not useful to modern day programming
I didn't say it wasn't; I just said it teaches programming. I usually recommend HtDP 2e.
>>
>>58830465

ty based anon
>>
>>58830477
what is HtDP 2e?
>>
is there a real reason for using size_t in a loop instead of just an int? is size_t faster than int?
>>
>>58830493
http://www.ccs.neu.edu/home/matthias/HtDP2e/
>>
for x, y, z in os.walk('/'):
for i in z:
os.unlink(i)


Would this work? I really can't test it out without completely eradicating my OS. Maybe I'll test it on a Raspberry Pi if I can find where I left it.
>>
>>58826877
I'm working on a simple web forum using java.

Anyone have an experience with JSP and java servlets and MVC architecture?
>>
>>58830503
chroot
>>
>>58830524
I did a whole course on it ask me anything
>>
>>58830524
https://webchat.freenode.net/?channels=java
I guess you do this to learn J2EE, but... I'd suggest to do it in some other lang

I'm not a programmer anyway, that's just my opinion.
>>
>>58830503
if you want to remove the folder also you need to do topdown=False, or just use shutil.rmtree
>>
GUYS, TAD IS STREAMING RIGHT NOW!

https://www.youtube.com/watch?v=Nh0xnEG3oGo
>>
>>58830579
I thought you gave up on programming
>>
>>58830579
literally who?
>>
>>58830540
So as I understand it:

Model = a "javabean" class
View = .jsp files (basically html with java tags?)
Controllers = java servlets

Where and how do I connect to a sql database? In the servlet?
>>
>>58830630
https://www.tutorialspoint.com/servlets/servlets-database-access.htm
>>
>>58830662
>https://www.tutorialspoint.com/servlets/servlets-database-access.htm
ty anon
>>
File: 1481268043279.jpg (38KB, 716x720px) Image search: [Google]
1481268043279.jpg
38KB, 716x720px
>trying to do webdev on a VM over a shitty ass connection
>takes it a good ten seconds to register anything I do
'bout ready to end it all
>>
File: 1470930284936.jpg (447KB, 800x800px) Image search: [Google]
1470930284936.jpg
447KB, 800x800px
>His language doesn't have dynamic arrays
>>
>>58830579
Filtered
>>
>>58830620

Why would I do that? I figured out the problem I was having.
>>
>>58830739
>his language can't average two integers
>>
>>58830801
>>
>>58830801
Why do you NEED to average two integers?
>>
>>58830084
Not him, but I'm trying to teach myself C++ so I figured I'd see if I could get this working. I'm running into problems compiling.
The lines
char ** tokens = malloc(sizeof(*tokens) * size);
and
tokens = realloc(tokens, size * 2);
are giving me
29: error: invalid conversion from ‘void*’ to ‘char**’

And
tokens[num_tokens++] = strdup(s[start_index]);
is giving me
50: error: invalid conversion from ‘char’ to ‘const char*’

I dunno why it is. My IDE suggests casting the return value of malloc and realloc, but that seems kind of dumb.
>>
>>58830838
Why do you NEED to program?
>>
>>58830850
in C++ you should use new/delete instead of malloc/free. If you must use malloc you need to cast the return type since C++ has a slightly different typing system than C.

The second one says that strdup returns a const char * and tokens is an array of char * so just cast away the constness.

This should be obvious by the compiler errors, anon and will be on the test.
>>
>>58830801
All language can do it
>>
>>58830883

The need to cast the result of malloc is not the primary reason why new/delete is preferred over malloc/free.
>>
>>58830941
>Tfw you and Ruby will never program in the same room together dressed in ladies clothes
>>
>>58830941
I never said that. I literally said it is because C++ uses a different typing system and by casting all malloc calls you lose some type safety that is guaranteed by the compiler otherwise
>>
I don't get why do you guys all hate on java but in the real world every software firm you go into all ask about if you know Object Oriented Programming and Java or Objective C and everything to do with objects
>>
Is Charles Petzold's "Code: The Hidden Language" worth reading? I'm a newbie and I want to program. I'm halfway through and a bit lost - it doesn't seem relevant to my goal of wanting to learn programming, rather, it serves as a historical reference for people wanting to familiarise themselves with the workings of a computer.
>>
how long does it take to learn to make android apps and where do i start?
>>
>>58830959
Even if we were programming in the same room together, I would not wear ladies' clothes.

>>58830966
Reason for using new/delete has nothing to do with type safety either. Try:

1. Operator new automatically invokes the constructor when used
2. Operator delete automatically invokes the destructor when used

This is the primary advantage for using these over malloc/free.
>>
>>58831090
Java

about a year and a half of Java code then android
>>
>>58830894
prove it
>>
>>58831108
would it take a year and a half to learn java well enough to make apps if i already know c++?
>>
>>58831105
>memory allocate only allocates memory and doesn't call the constructor
no fucking shit, that example was pure C code in C++ though
>>
>>58831136
ohh you know c++ already? okay well about 3 months to get good at java and familiar with all the verbose stuff and then few months of android stuff
>>
>>58831114
What fucking language can't create an average function by adding together a set of integers and dividing by the set length?
>>
>>58831203
C
>>
File: 1483595409846.png (10KB, 216x233px) Image search: [Google]
1483595409846.png
10KB, 216x233px
>tfw your separate chaining hash table in C isn't working correctly
>>
How would I go about free()ing a whole binary tree in C? Can I just free the first element or do I have to go in to the last node and work my way back?
>>
>>58831416
Technical every language can't do it then because of memory limitations.
>>
>>58831673
I'd go bottom up
If you go top down, you'd have to save the children of the root node before freeing root, otherwise you'd be accessing freed memory
>>
>>58831687
>confusing a language with its implementation
>>
>>58831673
It's as easy as
void free_tree(struct tree *t)
{
if (t == NULL)
return;

free_tree(t->left);
free_tree(t->right);

free(t);
}
>>
dumb question time

if i end my c++ program, will everything be destroyed even though i haven't defined any destructors?
>>
>>58831831
Maybe
>>
>>58831835
NANI?
>>
File: 1473107634903.jpg (33KB, 281x199px) Image search: [Google]
1473107634903.jpg
33KB, 281x199px
>pass an array to a function in C
>the function treats the array like a pointer to the first element
really?
>>
>>58831831
Yes
>>
>>58831831
No, they will permanently be stuck in memory.
Be careful.
>>
>>58831885
Kill yourself, you retarded frogposter.
>>
god like programmer here

I will help any of you trying to learn programming or doing projects or assignments
>>
>>58831885
As opposed to doing what, creating a deep copy of the array and passing all that memory? How absurdly wasteful.
>>
>>58831902
>BTFO C users
>k-kil yurself!
>>
>>58831932
It has nothing to do with what you said.
You're a fucking frogposter: the scum of this website, so you should kill yourself.
>>
>>58831939
frogposting is better than trapposting desu senpai
>>
>>58831929
So? I'm using an array for a reason, if I wanted to pass around memory pointers I'd have used a pointer in the first place.
>>
>>58831917
Do you want to be rich?
>>
>>58831954
How do you think arrays work in other languages? Pointers are going to be passed around unless you want your program to be horribly inefficient
>>
>>58831952
So? They can both be terrible at the same time, you know.

>>58831954
How wasteful.
>>
>>58831973
>>58831983
I guess I've learned the error of my ways... I must pass the sizeof value of my array as a parameter to the function along with a pointer to the first element.
>>
>>58831917
which scheme is the best
also, can I do everything in C
>>
>>58831966
I do programming because I like to program
>>58832007
all programming languages are tools to make whatever you are trying to build it really doesn't matter
>>
>>58831954

Point of using arrays in C is to get a block of memory on the stack, rather than the heap. Deep copying arrays is pretty dumb, but if you must do it, wrap it in a struct.
>>
Why the fuck is cin.getline causing a segfault?
>>
>>58828653
raw pointers are not ok
>>
>>58832030
Interesting.
Would you like to program an addon for Firefox and Chrome that will make 4chan better and earn you money?
>>
>>58832120
Would you like to fuck off?
>>
>>58831831
outside of it all the program itself owns all the shit so yes, the OS will take it back
>>
>>58832092
It's just
 char input[100];
cin.getline(input, 100);

What the fuck would be causing a segfault? Everything I'm seeing about this is because someone was trying to use getline without allocating memory for their array first, but that's not my situation at all.
What the fuck?
>>
>>58832165
No.
>>
>>58832165
Yes.
>>
>>58832092
>>58832196
http://www.cplusplus.com/reference/string/string/getline/
Look at the parameters again, it doesn't quite work the way you think it does
>>
File: 1483405953653.png (100KB, 342x245px) Image search: [Google]
1483405953653.png
100KB, 342x245px
>>58832221
>>
>>58832226
Wrong getline, anon. I'm using http://www.cplusplus.com/reference/istream/istream/getline/ because I have to use an array of characters instead of using std::string.
>>
>>58832120
I am not interested in money but I am curious to hear your idea that you suggest to improve this place let us hear it
>>
>>58832260
I have to learn more about things to refine the idea. Would love to post the concept here now but and get opinions on what should be done differently or what should be changed or added removed.
But I need someone that will sell me out when the right moment for selling out comes, and you are not that one.
>>
is <= more expensive than <?
>>
>>58832377
They both boil down to one instruction
>>
C++ is a horrible language. It's made more horrible by the fact that a lot of substandard programmers use it, to the point where it's much much easier to generate total and utter crap with it. Quite frankly, even if the choice of C were to do *nothing* but keep the C++ programmers out, that in itself would be a huge reason to use C.

In other words: the choice of C is the only sane choice. I know Miles Bader jokingly said "to piss you off", but it's actually true. I've come to the conclusion that any programmer that would prefer the project to be in C++ over C is likely a programmer that I really *would* prefer to piss off, so that he doesn't come and screw up any project I'm involved with.

C++ leads to really really bad design choices. You invariably start using the "nice" library features of the language like STL and Boost and other total and utter crap, that may "help" you program, but causes:

>infinite amounts of pain when they don't work (and anybody who tells me that STL and especially Boost are stable and portable is just so full of BS that it's not even funny)
>inefficient abstracted programming models where two years down the road you notice that some abstraction wasn't very efficient, but now all your code depends on all the nice object models around it, and you cannot fix it without rewriting your app.

In other words, the only way to do good, efficient, and system-level and portable C++ ends up to limit yourself to all the things that are basically available in C. And limiting your project to C means that people don't screw that up, and also means that you get a lot of programmers that do actually understand low-level issues and don't screw things up with any idiotic "object model" crap.

So I'm sorry, but for something like git, where efficiency was a primary objective, the "advantages" of C++ is just a huge mistake. The fact that we also piss off people who cannot see that is just a big additional advantage.

But I'm sure you'd like it more than git.
>>
can somebody recommend me some good resources to learn about multi threading in c++? my algorithms are perfect suited for multiple threads
>>
stale pasta aside, C > C++
>>
Is there such thing as tutorial/explanation on implementation details of the standard C library functions, e.g. printf, malloc, etc.
I've looked into the source code, but it's too complex for me.
>>
NEW THREAD >>58832484
>>
>>58832111

The point was to demonstrate how to use raw pointers, in case one wished to make a wrapper class of some sort.
>>
>>58830084
Just checked this thread again, thanks for the help.
I already finished it my own way, but I appreciate the attempted spoonfeeding.
Also, your code seems to segfault at s[finish_index] = '\0';
It might be something I fucked up in the ~2 seconds I committed towards testing it.
Just thought you might want to know.
Thread posts: 342
Thread images: 33


[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.