Go to advanced search

by jahboater
Sat Oct 26, 2019 3:18 pm
Forum: C/C++
Topic: file input
Replies: 5
Views: 997

Re: file input

100k is tiny and I think Heaters suggestion to read it all into a buffer at once and parse repeatedly from there, is likely the simplest option. You could even memmap the file but its probably not worth the bother. Either way you just get a large array of characters that you can simply scan with str...
by jahboater
Fri Oct 25, 2019 4:38 pm
Forum: Networking and servers
Topic: How install "gpio"-program in /usr/local/bin
Replies: 6
Views: 656

Re: How install "gpio"-program in /usr/local/bin

You can/should use "install" to install programs into /usr/local/bin

sudo install myprog /usr/local/bin

or a little more complicated:

sudo install -s -C -o bin -g bin myprog /usr/local/bin

see "man install"
by jahboater
Fri Oct 25, 2019 8:41 am
Forum: Troubleshooting
Topic: Can't start an executable python program
Replies: 4
Views: 202

Re: Can't start an executable python program

Looks like you are running the program in two different places.
When you open the file, you should give it the full path such as "/home/pi/Desktop/file.txt".
The environment variable $HOME may be useful unless you are starting it from /etc/rc.local or cron.
by jahboater
Thu Oct 24, 2019 9:50 am
Forum: Troubleshooting
Topic: "chmod" and "chown" don't work on USB memory sticks
Replies: 9
Views: 413

Re: "chmod" and "chown" don't work on USB memory sticks

If the type is vfat then you cant set ownership and permissions as it is a Microsoft format. FAT file systems are very simple and do not have any concept of file ownership. The mount options uid=xxxx and gid=xxxx set the "pretend" owner for the filesystem as a whole so that its usable by Linux (see...
by jahboater
Thu Oct 24, 2019 5:33 am
Forum: C/C++
Topic: Finding control Characters in string
Replies: 22
Views: 1829

Re: Finding control Characters in string

Actually, I don't understand why the assignment: int pos = p - str; does not produce a warning as both p and str are pointers and we have potential information loss. You need -Wconversion Then you get try.c: In function 'main': try.c:28:11: error: conversion from 'long int' to 'int' may change valu...
by jahboater
Thu Oct 24, 2019 4:00 am
Forum: C/C++
Topic: Finding control Characters in string
Replies: 22
Views: 1829

Re: Finding control Characters in string

int pos = p - &str[0];

will only work on a 32-bit platform. It does compile on Raspbian, but not elsewhere.

It should be:

long pos = p - str;

or for C99 and later:

ptrdiff_t pos = p - str;
by jahboater
Thu Oct 24, 2019 12:03 am
Forum: C/C++
Topic: Finding control Characters in string
Replies: 22
Views: 1829

Re: Finding control Characters in string

Or, as Heater noted:

strchr( str, '\t' ) // find TAB

strchr( str, '\r' ) // find CR
by jahboater
Wed Oct 23, 2019 1:34 pm
Forum: Raspbian
Topic: Raspbian Buster Lite stop all writes to SDCARD
Replies: 13
Views: 866

Re: Raspbian Buster Lite stop all writes to SDCARD

My /etc/fstab look like this: proc /proc proc defaults 0 0 PARTUUID=d9b3f436-01 /boot vfat defaults 0 2 PARTUUID=d9b3f436-02 / ext4 defaults,noatime,commit=600 0 1 tmpfs /tmp tmpfs defaults,noatime 0 0 tmpfs /var/log tmpfs defaults,noatime,size=16m 0 0 You can see the /tmp directory is in virtual me...
by jahboater
Wed Oct 23, 2019 11:46 am
Forum: General discussion
Topic: Timeframe for USB C power board revision
Replies: 33
Views: 7353

Re: Timeframe for USB C power board revision

HawaiianPi wrote:
Wed Oct 23, 2019 11:37 am
They didn't mess up big time, it's a minor inconvenience, with multiple simple solutions.
And several million users have had no problems.
by jahboater
Tue Oct 22, 2019 10:46 pm
Forum: General discussion
Topic: RPi 4 power consumption vs. RAM
Replies: 15
Views: 2080

Re: RPi 4 power consumption vs. RAM

Frequently for systems running unattended just nothing... Unused memory gets used for disk cache. Well...maybe. Given that the system issues a sync command periodically, those disk caches will get cleared. The dirty pages get flushed. Others remain. Plus, not all programs write very much, so not mu...
by jahboater
Tue Oct 22, 2019 7:17 pm
Forum: General discussion
Topic: RPi 4 power consumption vs. RAM
Replies: 15
Views: 2080

Re: RPi 4 power consumption vs. RAM

rin67630 wrote:
Tue Oct 22, 2019 10:21 am
hitsware wrote:
Sun Oct 20, 2019 1:53 am
What performance enhancement does more RAM provide ?
Frequently for systems running unattended just nothing...
Unused memory gets used for disk cache.
by jahboater
Tue Oct 22, 2019 6:47 pm
Forum: Raspbian
Topic: Any Text Editors built specifically for the Pi?
Replies: 19
Views: 1274

Re: Any Text Editors built specifically for the Pi?

I guess it just serves a purpose. One thing I do know is that I like the way Mu dark looks. So as I don't have any real preferences yet, might as well go from there. Maybe still try VIM lol. Don't know yet. So when trying to install VSCode I need to look at different versions of it and end up with ...
by jahboater
Tue Oct 22, 2019 4:30 pm
Forum: Raspbian
Topic: Any Text Editors built specifically for the Pi?
Replies: 19
Views: 1274

Re: Any Text Editors built specifically for the Pi?

Heater wrote:
Tue Oct 22, 2019 3:48 pm
Bill Joy created vi so as to make good use of the full screen editing capabilities of the, at the time new, CRT based terminals.
I imagine "ed" would work really well on a 300 baud serial line.

ed is included as standard with Raspbian, try "ed filename" - its really friendly :)

:) :) :)
by jahboater
Sun Oct 20, 2019 10:07 pm
Forum: Beginners
Topic: Why buy 32GB or less MicroSD card when 64GB is a few dollars more?
Replies: 26
Views: 1785

Re: Why buy 32GB or less MicroSD card when 64GB is a few dollars more?

On a purely "per gigabyte" measure, the 128GB card is not 'a few dollars more', but in fact "multiple dollars less" ... The larger card will take longer to reach its maximum read/write/erase cycles as well, so the value further increases. In addition, the usage may be simpler with all the data on a...
by jahboater
Sun Oct 20, 2019 7:17 pm
Forum: General discussion
Topic: RPi 4 power consumption vs. RAM
Replies: 15
Views: 2080

Re: RPi 4 power consumption vs. RAM

How does more RAM help performance ? It depends what you are running. Some software needs (wants) more memory than others. If you haven't got enough RAM available it will use virtual memory (swap space on the SD card) instead and run really slowly. Also if you are running multiple things at the sam...
by jahboater
Sun Oct 20, 2019 6:02 pm
Forum: General discussion
Topic: RPi 4 power consumption vs. RAM
Replies: 15
Views: 2080

Re: RPi 4 power consumption vs. RAM

The maximum memory size is 4GB.
hitsware wrote:
Sun Oct 20, 2019 5:52 pm
How does more RAM help performance ?
Please read Paeryn's post again.
by jahboater
Sun Oct 20, 2019 5:36 pm
Forum: Beginners
Topic: Power supply
Replies: 8
Views: 596

Re: Power supply

Thanks for the reply of course I meant power supply (my fault). But would I power the raspberry pi with an ps4 controller charger (it is a micro usb) if it was inserted in a pc or would I need to get the official power supply? I would get the "official" power supply. It is cheap to buy, is good qua...
by jahboater
Sat Oct 19, 2019 8:07 pm
Forum: Beginners
Topic: Why buy 32GB or less MicroSD card when 64GB is a few dollars more?
Replies: 26
Views: 1785

Re: Why buy 32GB or less MicroSD card when 64GB is a few dollars more?

I do not have any need for larger cards and I find 16Gb a good balance between cost and size - it has plenty of space for O/S and wear but costs less than other cards. Looking at Amazon for the well regarded Sandisk A1 class cards, 32GB is cheaper than 16GB. https://www.amazon.co.uk/SanDisk-microSD...
by jahboater
Fri Oct 18, 2019 6:11 pm
Forum: C/C++
Topic: C's 'printf'
Replies: 27
Views: 2631

Re: C's 'printf'

Heater wrote:
Fri Oct 18, 2019 5:30 pm
Oh and how come after all this time getting the frikken carry flag/overflow flags is so hard?
That's easy, but its a GCC extension.

Obviously not truly portable, but then GCC is available on so many platforms, and I bet Clang can do it too.
by jahboater
Fri Oct 18, 2019 6:04 pm
Forum: C/C++
Topic: C's 'printf'
Replies: 27
Views: 2631

Re: C's 'printf'

fixing it;s undefined arithmetic, In C2x I believe. So we see that what sal55 is saying is not unreasonable or beyond the bounds of possibility, it's been done. Its been done in an entirely new language, and I think Algol68 did it a very long time ago. /* edit: sorry PeterO, you got there first! */...
by jahboater
Fri Oct 18, 2019 2:04 pm
Forum: C/C++
Topic: C's 'printf'
Replies: 27
Views: 2631

Re: C's 'printf'

Yes, that (PRId64 etc) is little messy, but it works fine, is precise, and is portable. Only from inside C. I've generally called routines such as printf as foreign functions from other languages Can I ask why? Do these other languages not have their own formatted I/O? or is their I/O not as capabl...
by jahboater
Fri Oct 18, 2019 10:27 am
Forum: C/C++
Topic: C's 'printf'
Replies: 27
Views: 2631

Re: C's 'printf'

You're mixing up the two pieces of information that 'printf' functions need to know for each argument: the type of the thing to be printed, and optional formatting information that affects its appearance. I know how printf works, I have been using it for 40 years or so! although it's apparently not...
by jahboater
Thu Oct 17, 2019 12:45 pm
Forum: C/C++
Topic: Where can I begin learning C/C++?
Replies: 67
Views: 7453

Re: Where can I begin learning C/C++?

My own compilers are rather simple: there are no warnings, only hard errors. And they will show the first error and then stop. That's precisely what "-Werror -Wfatal-errors" does for GCC. -Werror makes all warnings into hard errors. -Wfatal-errors abandons the compilation after the first error. You...
by jahboater
Thu Oct 17, 2019 4:11 am
Forum: C/C++
Topic: Where can I begin learning C/C++?
Replies: 67
Views: 7453

Re: Where can I begin learning C/C++?

Is there any way to turn off all that ASCII art? It's filling my screen and causing the error messages to scroll off the top. Not the same, but you can reduce the amount of error message output from gcc: $ g++ -Werror -Wfatal-errors try.cpp try.cpp: In function 'int main()': try.cpp:5:12: error: no...
by jahboater
Thu Oct 17, 2019 12:13 am
Forum: C/C++
Topic: Where can I begin learning C/C++?
Replies: 67
Views: 7453

Re: Where can I begin learning C/C++?

g++ 9.2 gives:- $ g++ try.cpp try.cpp: In function 'int main()': try.cpp:5:12: error: no match for 'operator>>' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'const char [15]') 5 | std::cout >> "Hello, world!\n"; | ~~~~~~~~~ ^~ ~~~~~~~~~~~~~~~~~ | | | | | const char [15] | s...

Go to advanced search