I’m in the process of learning C/C++ and thought I’d see what the Internet had to say about C/C++ coding conventions.
In the process, I stumbled upon the Google C++ Style Guide, and a much better read, Making Wrong Code Look Wrong
by Joel Spolsky.
Principal Software Engineer/Architect, motorcyclist, drummer, and artist
I’m in the process of learning C/C++ and thought I’d see what the Internet had to say about C/C++ coding conventions.
In the process, I stumbled upon the Google C++ Style Guide, and a much better read, Making Wrong Code Look Wrong
by Joel Spolsky.
Most high level languages have some sort of String.split([delimiter]) method to create an array of Strings tokenized by a user specified delimiter. This is a simple way to convert a CSV into an array.
Here is a quick way to do that in a bash shell script:
#!/bin/bash
SOURCE_STRING='foo|blah|moo'
# Save the initial Interal Field Separator
OIFS="$IFS"
# Set the IFS to a custom delimiter
IFS='|'
read -a TOKENS <<< "${SOURCE_STRING}"
for i in "${TOKENS[@]}"
do
echo "$i"
done
# Reset original IFS
IFS="$OIFS"