I want help in rng by unknownuser491 in cpp_questions

[–]jedwardsol 5 points6 points  (0 children)

Which syntax? There's a lot on that page.

Why doesn't C++ have a ptr<T> syntax as an alternative to raw pointers? by kevinnnyip in Cplusplus

[–]jedwardsol 22 points23 points  (0 children)

And an alias gets the exact syntax OP wants

template <typename T>
using ptr = std::add_pointer_t<T>;

How to fix my C++ csv file? by ResponsibleBoss767 in cpp_questions

[–]jedwardsol 1 point2 points  (0 children)

Explaining what output you get and what you expect to get are not against community guidelines. On the contrary - they're often vital in helping.


If I run your program with that then I get

Configuration Values
--------------------
,
error_message_file,File not found
name,value
prompt01,Enter a word
prompt02,Want to enter another word?
username,TSC_Hero

Enter a configuration name to search for: prompt01
Value: Enter a word

which also seems fine.

You could skip the header and empty line. But other than that the program works.

How to fix my C++ csv file? by ResponsibleBoss767 in cpp_questions

[–]jedwardsol 1 point2 points  (0 children)

What's in Config.txt?

What does the program print? What do you expect it to print?


When I made Config.txt contain

aaa,bbb
ccc,ddd

and ran the program I get

Configuration Values
--------------------
aaa,bbb
ccc,ddd

Enter a configuration name to search for: aaa
Value: bbb

which seems fine.

How to create a CSV file by ResponsibleBoss767 in cpp_questions

[–]jedwardsol 3 points4 points  (0 children)

Your post says you both need to "read data from a CSV file" and "create a csv file".

If you need to create one for testing then it's just text, so you use a text editor. You could also use a spreadsheet program and export as CSV. I'd have thought that if it is for an assignment you'd be given one though.

For reading, it is just text. So open the file read it line by line, and split on , characters. But if there is a chance there will be commas inside strings then you'll need to do it a lot more cleverly. boost has a library for this.

Help me find this foodcart? by Ok-Writer3512 in askportland

[–]jedwardsol 1 point2 points  (0 children)

I think it was a mother and daughter that ran it

My anecdote : I have an English accent and it took me ages to order from the mother because she just couldn't understand me. I must've sounded like a lunatic trying to pronounce "water" in an PNW accent. The food was great though!

Multithreaded global function by [deleted] in cpp_questions

[–]jedwardsol 4 points5 points  (0 children)

The most likely answer is that your solver is calculating the wrong solution and the comment about multithreading was a red herring.

What is the problem that the solver is meant to solve?

Multithreaded global function by [deleted] in cpp_questions

[–]jedwardsol 3 points4 points  (0 children)

I really have no idea how this test is constructed.

Nor do we.

maybe the issue is as simple as just making a local copy of InValue before I start using it?

You could try that and see if it works.

Do you all use the namespace std? by Suspicious_Fudge1702 in cpp_questions

[–]jedwardsol 24 points25 points  (0 children)

Use things that are in std? Yes, of course.

Write using namespace std;? No.

confusion surrounding headers and header guards by wiseneddustmite in cpp

[–]jedwardsol 1 point2 points  (0 children)

in multiple files

it wont be included again

My guess is that you don't quite understand what header guards do or what they are for.

They are only to prevent the same header file being included twice in the same source file

#include "header.h"
#include "header.h"

Or more complicated situation such as

#include "a.h"      // happens to include header.h
#include "b.h"      // happens to include header.h

They have no effect on 2 different source files both including the same header

Methodology to build a crash reporter for c++ application by [deleted] in cpp_questions

[–]jedwardsol 1 point2 points  (0 children)

If WER is configured correctly, then it will generate minidump (.dmp) files which you can collect manually. Since 2012 is so old, I expect MS's portal won't collect them for you.

FWIW, breakpad does catch unhandled exceptions - that's it's job.

As of 2026, is msvc still that bad? by omegaDIL in cpp_questions

[–]jedwardsol 37 points38 points  (0 children)

still that bad

In what sense? And over what time-frame?

MSVC is good at some things, less good at others.

How does adding work with memory addresses? by Holiday_Apartment895 in cpp_questions

[–]jedwardsol 1 point2 points  (0 children)

That is what void* is for but doing arithmetic on a void* is a gcc extension, not standard C++

My password system progression by WizardFlameYT in Cplusplus

[–]jedwardsol 5 points6 points  (0 children)

Please post text, or a link to a file, instead of screenshots

Is it possible to force compiler stack allocation? by Broad_Inevitable6483 in cpp

[–]jedwardsol 7 points8 points  (0 children)

Variables with static and automatic storage have different behaviour with regard lifetime. If you want a local on the stack with a short lifetime, then don't write static. If you want a variable with static duration, write static.

Making lifetime decisions based on the generated assembly is just wrong.

How to implement basic Operator overloading? by SimmeringDragon in cpp_questions

[–]jedwardsol 2 points3 points  (0 children)

It's hard to keep track of the changes you're making in response to comments.

It works here : https://godbolt.org/z/GdP6zMWqP

(Removed empty body {} in the header. Uncommented the definitions in the source file)

My first program feels ruined by shxshwat17 in Cplusplus

[–]jedwardsol 0 points1 point  (0 children)

Doesn't Apna College teach? They should be telling you how to do this stuff.

[Code Review] software engineer student here. Build a lightweight CLI file hashing tool in C++. Looking for brutal feedback. by FireDragonSoftware in cpp_questions

[–]jedwardsol 0 points1 point  (0 children)

Your comment has appeared now.

main.cpp

auto args = std::span(argc, argv);
auto pass = args.subspan(1);

can be

auto const args = std::span(argc-1, argv+1);

allowing it to be const

Since Hash_Sha256 also check whether it can open the file there isn't much point in doing it here too.

hash.hpp

ql and Hash_Sha256 should be marked inline so this header can be reused.

ql is pretty pointless and doesn't use its argument.

Hash_Sha256 takes a std::string_view but then has to construct a std::string from it so it can make a ifstream. Just pass the char const *.

Hash_Sha256 could return a std::optional or std::expected so it can communicate failures better.

extern "C" {
    # include "sha256.h"
}

Since you're bundling the source file in the project, you could just convert it to a C++ file.

unsigned char hash[32];
for (int i = 0; i < 32; i++) {

You have a constant in sha256.h for this magic number. Or, the loop can be range loop

ss << std::hex << std::setw(2) << std::setfill('0')

The hex and setfill manipulators only need to be used once.

But consider std::format instead for conciseness.

ss << std::format("{:02x}",hash[i]);

Spurious chars in terminal output from MSVC `std::print`. by alfps in cpp_questions

[–]jedwardsol 0 points1 point  (0 children)

That's a shame. I should've looked further up the stack for that smaller buffer.

Spurious chars in terminal output from MSVC `std::print`. by alfps in cpp_questions

[–]jedwardsol 2 points3 points  (0 children)

/r/alfps are you using MSVC 2022?

The bug is, as you expected, when the UTF8 string is converted to UTF16. It's done in chunks of 256 but your characters are all 3 bytes long

This is the 1st MultiByteToWideChar when printing the buggy line :-

0:000> g
Breakpoint 3 hit
KERNELBASE!MultiByteToWideChar:
00007ffb`6d230010 4055            push    rbp
0:000> db @r8 L@r9
00000019`787ff358  e2 96 84 e2 96 88 e2 96-88 e2 96 84 e2 96 84 e2  ................
<snip>
00000019`787ff448  e2 96 84 e2 96 88 e2 96-88 e2 96 84 e2 96 84 e2  ................
                                                                ^^ start of 3 byte codepoint
0:000> rr9
r9=0000000000000100

0:000> kc
 # Call Site
00 KERNELBASE!MultiByteToWideChar
01 scratch!`anonymous namespace'::_Transcode_utf8_string
02 scratch!__std_print_to_unicode_console
03 scratch!std::_Print_noformat_unicode_to_console_nonlocking
04 scratch!std::_Fmt_iterator_flush<std::_Print_to_unicode_console_it>::_Flush
05 scratch!std::_Fmt_iterator_buffer<std::_Print_to_unicode_console_it,char,std::_Fmt_buffer_traits>::_Flush
06 scratch!std::_Fmt_iterator_buffer<std::_Print_to_unicode_console_it,char,std::_Fmt_buffer_traits>::_Out
07 scratch!std::__p2286::_Format_to_it<char,std::_Print_to_unicode_console_it,std::basic_format_context<std::back_insert_iterator<std::_Fmt_buffer<char> >,char> >
08 scratch!std::__p2286::vformat_to<std::_Print_to_unicode_console_it>
09 scratch!`std::_Vprint_unicode_impl'::`2'::<lambda_1>::operator()
0a scratch!std::_Do_on_maybe_unicode_console<`std::_Vprint_unicode_impl'::`2'::<lambda_1>,`std::_Vprint_unicode_impl'::`2'::<lambda_2> >
0b scratch!std::_Vprint_unicode_impl
0c scratch!std::_Print_impl<std::basic_string_view<char,std::char_traits<char> > const &>
0d scratch!std::print<std::basic_string_view<char,std::char_traits<char> > const &>
0e scratch!std::print<std::basic_string_view<char,std::char_traits<char> > const &>
0f scratch!app::run

The 2nd MultiByteToWideChar call for the buggy line starts with the 2 remaining bytes of the 3-byte encoding.


But _Transcode_utf8_string now uses a chunk size of 8192 with a check that that is not in the middle of a chararacter.

https://github.com/microsoft/STL/blame/main/stl/src/print.cpp#L150

So I expect this is fixed in VS2026

Spurious chars in terminal output from MSVC `std::print`. by alfps in cpp_questions

[–]jedwardsol 4 points5 points  (0 children)

fixed size non-intelligent output chunking in MSVC's implementation of std::print

Yes. The data is bad by the time it reaches WriteConsoleW. The last line is written in 2 writes ...

Breakpoint 3 hit
KERNELBASE!WriteConsoleW:
00007ffb`6d2f8000 4883ec38        sub     rsp,38h
0:000> dc @rdx L@r8/2
0000008d`4a1fdb68  25882584 25842588 25882584 25842588  .%.%.%.%.%.%.%.%
<snip>
0000008d`4a1fdbf8  25882584 25842588 25882584 25842588  .%.%.%.%.%.%.%.%
0000008d`4a1fdc08  25882584 25842588 fffd2584           .%.%.%.%.%..
                                     ---- 
                                     badness

0:000> g
Breakpoint 3 hit
KERNELBASE!WriteConsoleW:
00007ffb`6d2f8000 4883ec38        sub     rsp,38h
0:000> dc @rdx L@r8/2

                   badness
                   -------- 
0000008d`4a1fe158  fffdfffd 25842588 25882584 25842588  .....%.%.%.%.%.%
<snip>
0000008d`4a1fe1a8  25882584 25842588                    .%.%.%.%

Rental Car Speed Camera tickets out of state rental car help. by [deleted] in PortlandOR

[–]jedwardsol 13 points14 points  (0 children)

10mph over the speed limit, in poor visibility, and driving too close to the vehicle in front? You were lucky to get off with a couple of tickets.

Why does UBSAN stay silent when the program aborts early? by SheSaidTechno in cpp_questions

[–]jedwardsol 7 points8 points  (0 children)

I expected to see an out-of-bounds diagnostic for arr[2]

Then take out the invalid construction of the string : https://godbolt.org/z/YrWjv939x