#include <iostream>
#include <string.h>
usingnamespace std;
//prototype
int processline(char*);
int GetString();
int main()
{
GetString();
}
int GetString()
{
char buffer [300];
while (cin.getline (buffer, 300))
{
int wordCount = 0;
wordCount += processline (buffer);
cout << endl << "There were " << wordCount << " words." <<endl;
}
return 0;
}
int processline (char* buffer)
{
int i, count = 0, beg = 0, out =0;
int length = strlen(buffer);
buffer[length] = ' ';
buffer[length + 1] = '\0';
length += 2;
char output [300];
char space = ' ';
for (i=0; i < length; i++)
{
if (isspace(buffer[i])!= 0)
{
if(i != beg)
{
strncpy((output+out), (buffer+beg), (i-beg));
out += i-beg;
//strcat(output+out, space);
output[out] = space;
out++;
count++;
}
beg = i+1;
}
}
output[out] = '\0';
cout << output << endl;
return count;
}
Warning:
1 2 3 4 5 6 7
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\string.h(157) : see declaration of 'strncpy'
1>Linking...
1>LINK : C:\Users\me\Documents\Visual Studio 2008\Projects\ydtkko\Debug\ydtkko.exe not found or not built by the last incremental link; performing full link
1>Embedding manifest...
1>Build log was saved at "file://c:\Users\me\Documents\Visual Studio 2008\Projects\ydtkko\ydtkko\Debug\BuildLog.htm"
1>ydtkko - 0 error(s), 1 warning(s)
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
OK basically you can ignore this error becaus in fact it is a warning.
In an incremental link the linker just replaces the code for the objects in the exe that have changed, it is quicker than a full link which is why it is done.
In a full link the executeable is create from the ground up.
This warning message is issued when you have deleted objects or other files that mean that the linker can not perform an incremental link. It can always do a full link. The warning message is just telling you that the information required for an incremental link is missing so the linker has opted to do a full link.