From 3b8bd83c014f9e62dc9db4dd697728b68f1195ec Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 18 Feb 2013 17:14:35 -0800 Subject: [PATCH] include string for memset and strcpy, use fscanf returns --- space/src/main.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/space/src/main.cpp b/space/src/main.cpp index d88c4fd004..a3ea710357 100644 --- a/space/src/main.cpp +++ b/space/src/main.cpp @@ -9,6 +9,8 @@ #include #include #include +#include + #include "TreeNode.h" #include "UDPSocket.h" @@ -93,13 +95,13 @@ bool loadSpaceData(void) { // pull as many bits as are left int goodBits = 8 - paddingBits; sprintf(formatString, "%%%dc", goodBits); - fscanf(configFile, formatString, fullByteBitString); + itemsRead = fscanf(configFile, formatString, fullByteBitString); // fill out the rest with zeros memset(fullByteBitString + goodBits, '0', paddingBits); } else { // pull 8 bits (which will be one byte) from the file - fscanf(configFile, "%8c", fullByteBitString); + itemsRead = fscanf(configFile, "%8c", fullByteBitString); } // set the corresponding value in the unsigned char array @@ -108,7 +110,7 @@ bool loadSpaceData(void) { char *nodeHostname = new char[MAX_NAME_LENGTH]; char *nodeNickname = new char[MAX_NAME_LENGTH]; - fscanf(configFile, "%s %s\n", nodeHostname, nodeNickname); + itemsRead = fscanf(configFile, "%s %s\n", nodeHostname, nodeNickname); findOrCreateNode(bitsInAddress, paddedAddress, nodeHostname, nodeNickname, 0); }