Good c++ Program

Hi Guru's
I wrote a shell script some days back.
i want to translate this script to a c++ program.I need help from you guys.I have never done any programming in c++ til now.

#!/usr/bin/ksh

inpFile=$1
outFile="$HOME/Output.txt"
errFile="$HOME/Error.txt"
dupFile="$HOME/Duplicate.txt"
tmpFile1=sample1.txt
tmpFile2=sample2.txt
sortFile=sortfile.txt

TOTAL_FILEDS=9
COUNT=1
PRINT_FLAG=0
LINE_NO=1
check_lines=0
rm -f $outFile $errFile $dupFile
sort $inpFile | uniq -d > $dupFile
#sort $inpFile | uniq -d | sed "s/$/& : Duplicate/g" >> $errFile
for line in $(cat $inpFile)
do
  	count_fields=$(echo $line | sed "s/00,*//g;s/,$//g" | wc -c)
	echo "count_fields is: $count_fields"
	cnt_flds1=$(echo $line | cut -d',' -f1-9 | sed "s/00,*//g;s/,$//g" | wc -c )
	echo "cnt_flds1 is : $cnt_flds1"
	cnt_flds2=$(echo $line | cut -d',' -f10-18 | sed "s/00,*//g;s/,$//g" | wc -c )
	echo "cnt_flds2 is : $cnt_flds2"
	cnt_flds3=$(echo $line | cut -d',' -f19-27 | sed "s/00,*//g;s/,$//g" | wc -c )
	echo "cnt_flds3 is : $cnt_flds3"
	if [[ $count_fields -eq 45 && $cnt_flds1 -eq 15 && $cnt_flds2 -eq 15 && $cnt_flds3 -eq 15 ]]
	then
            	PRINT_FLAG=0

		echo $line | cut -d',' -f1-9 > $sortFile
		echo $line | cut -d',' -f10-18 >> $sortFile
		echo $line | cut -d',' -f19-27 >> $sortFile

		while [[ $COUNT -le $TOTAL_FILEDS ]]
		do
                  	cut -d',' -f$COUNT $sortFile | grep -v 00 > $tmpFile1
			cut -d',' -f$COUNT $sortFile | grep -v 00 | sort > $tmpFile2

			diff $tmpFile1 $tmpFile2 > /dev/null
			if [[ $? -eq 1 || ! -s $tmpFile1 ]]
			then
                            	PRINT_FLAG=1
				break
fi
		COUNT=$((COUNT+1))
		done
		echo "Value of print flag is : $PRINT_FLAG"
		if [[ $PRINT_FLAG -eq 0 ]]
		then
			echo "$line : SUCCESS" >> $outFile
		else
			echo "$line : ERROR in $COUNT" >> $errFile
		fi
	else
		echo "$line : Out of Scope"  >> $errFile
	fi
	COUNT=1
	check_lines=$((check_lines+count_fields))
	if [[ $LINE_NO -eq 6 ]]
	then
		LINE_NO=0
		if [[ $check_lines -eq 270 ]]
		then
			echo " **** Success A Strip has 90 digits"
		else
			echo "----- Error,Check the above -----"
		fi
		check_lines=0
	fi
	LINE_NO=$((LINE_NO+1))
done
rm -f $tmpFile1 $tmpFile2 $sortFile
exit 0

The input file is----

00,11,21,00,00,55,00,73,83,07,00,22,39,43,00,66,00,00,00,15,00,00,44,58,67,00,87
02,14,24,30,00,00,00,70,00,00,00,00,32,47,50,60,74,00,04,16,27,38,00,00,00,00,89
00,00,00,00,42,52,61,71,86,01,00,29,33,00,59,00,75,00,03,19,00,00,45,00,68,00,88
00,13,20,31,00,00,64,76,00,05,00,00,35,41,56,00,00,81,00,00,28,00,00,57,65,79,90
06,10,00,36,40,00,00,00,80,00,12,25,00,00,51,62,72,00,09,00,00,37,49,00,69,00,84
00,17,23,00,46,53,00,77,00,08,00,00,34,00,54,00,78,82,00,18,26,00,48,00,63,00,85
00,14,23,39,00,00,60,00,87,02,00,28,00,41,50,00,75,00,03,15,00,00,44,00,68,00,90
00,16,25,35,00,53,00,71,00,08,00,00,36,40,00,62,00,88,00,00,27,37,00,58,64,78,00
05,10,00,00,48,52,00,73,00,00,00,24,31,00,57,66,00,81,07,17,00,00,49,00,00,79,85
00,00,20,33,00,00,63,70,80,06,12,00,34,42,56,00,00,00,00,00,29,00,00,59,69,74,86
04,13,00,32,43,00,65,00,00,00,18,22,00,00,55,00,72,84,09,00,00,38,47,00,67,00,89
01,11,21,00,00,51,00,76,00,00,00,26,30,45,54,00,00,82,00,19,00,00,46,00,61,77,83

Thanks

You might have to explain the logic again to the group, the giving the code wouldn't help. :slight_smile: