shell program- how many times a function is called

We have a program source C and is required to indicate how many times each function is called from the C program. also print the line number where there is a call.
I've tried something like this:

#!/bin/sh

for i in $*;do
    if ! [ $i.c ]
    then 
    echo $i is not a C file.
    else echo $i is a C file.
    fi
    echo "enter the string to search:"
    read string
    u=`grep -c $string $i`;
    v=`grep -n $string $i`;
        if [ $u -gt 0 ] 
        then 
            { echo $i contains the searched function, $u times.
            echo $v
            }
        else    echo ERROR- the file does not contain that function.
        fi

done

but for eg. if I give a file that isn't C source it doesn't show the right message.
also I'm not very sure that this is the right way to solve this problem, because it only works for the functions that you read from the keyboard , not for each function that you have in your program.
so if you have other ideas please help.
thank you. and sorry for my bad exprimation.