Skip to content

Instantly share code, notes, and snippets.

@goloveychuk
Created September 15, 2013 13:08
Show Gist options
  • Save goloveychuk/6570615 to your computer and use it in GitHub Desktop.
Save goloveychuk/6570615 to your computer and use it in GitHub Desktop.
void is_key_word()
{
char *buf=new char [100];
int buf_index=0;
char c;
int input_pos;
int shift=1;
bool end_of_file=0;
fstream f("1.txt");
f.seekg (0, f.end);
int length = f.tellg();
f.seekg (0, f.beg);
while (!f.eof())
{
f.get(c);
input_pos=(int)f.tellg();
if (c==' ' || c=='\n' || input_pos==length)
{
if (c=='\n')
shift=2;
else if (c==' ')
shift=1;
else
{
buf[buf_index++]=c;
shift=0;
}
buf[buf_index]='\0';
for (int i=0; i<keywords_len; i++)
if (strcmp(buf,keywords[i])==0)
{
input_pos=(int)f.tellg();
f.seekp(input_pos-buf_index-shift);
if (islower(buf[0]))
f.put(buf[0]-32);
f.seekg(input_pos);
break;
}
buf_index=0;
}
else
buf[buf_index++]=c;
}
f.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment