shift from java to c

updated to c