FILE* in C++ not reading entire file -


i'm having simple problem file, when read in file* , print out again after removing punctuations print out bottom part of file. input have below @ bottom of question. question : there reason why printing out section of file?

here's code reads in file:

int currentletter= 0;         string word = "";         file * input;          input = fopen("test.txt", "r");         if (input == null)         {              perror("error opening file");         }         else{             while(currentletter != eof){//loop through file                 do{// getword                     currentletter = fgetc(input);                     if(currentletter == '?' || currentletter == '<'|| currentletter == '>'|| currentletter == ':' ||currentletter == '\"')                         word += ' ';                     if (isalpha(currentletter) || isdigit(currentletter) || currentletter == '-' || currentletter == '\'' )                     {                         word += tolower(currentletter);                     }                  }while(currentletter != eof && currentletter != ' ' && currentletter != '\n');                  if (word != " "  && !(word.find_first_of("0123456789") < word.length()))                 {                     cout<< word << endl;                     // insert(word); called b                  }                 word = "";             }         } 

here input(quite big): collection of 5 memorable texts.

"i have, myself, full confidence if duty, if nothing neglected, , if best arrangements made, being made, shall prove ourselves once again able defend our island home, ride out storm of war, , outlive menace of tyranny, if necessary years, if necessary alone. @ rate, going try do. resolve of majesty's government-every man of them. of parliament , nation. british empire , french republic, linked in cause , in need, defend death native soil, aiding each other comrades utmost of strength. though large tracts of europe , many old , famous states have fallen or may fall grip of gestapo , odious apparatus of nazi rule, shall not flag or fail. shall go on end, shall fight in france, shall fight on seas , oceans, shall fight growing confidence , growing strength in air, shall defend our island, whatever cost may be, shall fight on beaches, shall fight on landing grounds, shall fight in fields , in streets, shall fight in hills; shall never surrender, , if, not moment believe, island or large part of subjugated , starving, our empire beyond seas, armed , guarded british fleet, carry on struggle, until, in god's time, new world, power , might, steps forth rescue , liberation of old." --winston churchill, 1940

"fourscore , 7 years ago our fathers brought forth on continent new nation, conceived in liberty , dedicated proposition men created equal. engaged in great civil war, testing whether nation or nation conceived , dedicated can long endure. met on great battlefield of war. have come dedicate portion of field final resting-place here gave lives that nation might live. altogether fitting , proper should this. in larger sense, cannot dedicate, cannot consecrate, cannot hallow ground. brave men, living , dead struggled here have consecrated far above our poor power add or detract. world little note nor long remember here, can never forget did here. living rather dedicated here unfinished work fought here have far nobly advanced. rather here dedicated great task remaining before us--that these honoured dead take increased devotion cause gave last full measure of devotion--that here highly resolve these dead shall not have died in vain, nation under god shall have new birth of freedom, , government of people, people, people shall not perish earth." --abraham lincoln

i today, friends, in spite of difficulties , frustrations of moment, still have dream. dream rooted in american dream. have dream 1 day nation rise , live out true meaning of creed: "we hold these truths self-evident: men created equal." have dream 1 day on red hills of georgia sons of former slaves , sons of former slave owners able sit down @ table of brotherhood. have dream 1 day state of mississippi, desert state, sweltering heat of injustice , oppression, transformed oasis of freedom , justice. have dream 4 children 1 day live in nation not judged colour of skin content of character. have dream today. --- martin luther king

the life , death of julies caesar william shakespeare

scene ii. public place.

flourish. enter caesar; antony, course; calpurnia, portia, decius brutus, cicero, brutus, cassius, , casca; great crowd following, among them soothsayer

caesar let me have men me fat; sleek-headed men , such sleep o' nights: yond cassius has lean , hungry look; thinks much: such men dangerous.

antony fear him not, caesar; he's not dangerous; noble roman , given.

caesar fatter! fear him not: yet if name liable fear, not know man should avoid spare cassius. reads much; great observer , looks quite through deeds of men: loves no plays, thou dost, antony; hears no music; seldom smiles, , smiles in such sort if mock'd himself , scorn'd spirit moved smile @ thing. such men never @ heart's ease whiles behold greater themselves, , therefore dangerous. rather tell thee fear'd fear; caesar. come on right hand, ear deaf, , tell me thou think'st of him.

"monty python , holy grail"

scene 25 head knight: nee! nee! nee! nee! arthur: you? head knight: knights say... nee! arthur: no! not knights nee! head knight: same! bedemir: they? head knight: keepers of sacred words: nee, pen, , nee-wom! random: nee-wom! arthur: hear them seldom live tell tale! head knight: knights nee demand sacrifice! arthur: knights of nee, simple travellers seek enchanter lives beyond these woods. head knight: nee! nee! nee! nee! arthur , party: oh, ow! head knight: shall 'nee' again if not appease us. arthur: well, want? head knight: want... shrubbery! [dramatic chord] arthur: what? head knight: nee! nee! arthur , party: oh, ow! arthur: please, please! no more! shall find shrubbery. head knight: must return here shrubbery or else never pass through wood alive! arthur: o knights of nee, , fair, , return shrubbery. head knight: 1 looks nice. arthur: of course. head knight: , not expensive. arthur: yes.
head knights: now... go!

scene 11

galahad: zoot! dingo: no, zoot's identical twin sister, dingo. galahad: oh, well, excuse me, i-- dingo: going? galahad: seek grail! have seen it, here in castle! dingo: no! oh, no! bad, bad zoot! galahad: it? dingo: oh, wicked, bad, naughty zoot! has been setting alight our beacon, which, remembered, grail-shaped. it's not first time we've had problem. galahad: it's not real grail? dingo: oh, wicked, bad, naughty, evil zoot! oh, naughty person, , must pay penalty -- , here in castle anthrax, have 1 punishment setting alight grail-shaped beacon. must tie down on bed , spank her! girls: spanking! spanking! dingo: must spank well. , after have spanked her, may deal like. , then, spank me. various girls: , spank me. , me. , me. dingo: yes, yes, must give spanking! girls: spanking! spanking!

scene 35 arthur: there is! bridge of death! robin: oh, great. knight: look! arthur: there's old man scene 24! bedemir: doing here? arthur: keeper of bridge of death. asks each traveller 5 questions-- knight: 3 questions. arthur: 3 questions. answers 5 questions-- knight: 3 questions. arthur: 3 questions may cross in safety. robin: if question wrong? arthur: cast gorge of eternal peril. robin: oh, won't go. knight: who's going answer questions? arthur: sir robin! robin: yes?
arthur: brave sir robin, go. robin: hey! i've got great idea. why doesn't launcelot go? launcelot: yes, let me go, liege. take him single-handed. shall make feint north-east-- arthur: no, no, hang on, hang on, hang on! answer 5 questions-- knight: 3 questions. arthur: 3 questions best can. , shall watch... , pray. launcelot: understand, liege. arthur: luck, brave sir launcelot. god you. keeper: stop! cross bridge of death must answer me these questions three, 'ere other side see. launcelot: ask me questions, bridge-keeper. i'm not afraid. keeper: name? launcelot: name sir launcelot of camelot.
keeper: quest? launcelot: seek holy grail.
keeper: favourite colour? launcelot: blue. keeper: right. off go. launcelot: oh, thank you. thank much. robin: that's easy! keeper: stop! approaches bridge of death must answer me these questions three, 'ere other side see. robin: ask me questions, bridge-keeper. i'm not afraid. keeper: name? robin: sir robin of camelot. keeper: quest? robin: seek holy grail. keeper: capital of assyria? robin: don't know that! auuuuuuuugh!
keeper: stop! name? galahad: sir galahad of camelot. keeper: quest? galahad: seek holy grail.
keeper: favourite colour? galahad: blue. no yel-- auuuuuuuugh! keeper: heh heh. stop! name? arthur: arthur, king of britons. keeper: quest?
arthur: seek holy grail. keeper: air-speed velocity of unladen swallow? arthur: mean? african or european swallow? keeper: what? don't know that! auuuuuuuugh! bedemir: how know swallows? arthur: well, have know these things when you're king know.

my output:

enter image description here

the problem text scrolling off top edge of command window , being lost. right-click icon on upper left edge of title bar, open "properties," , increase window/screen buffer sizes large amounts. try running again.

or, run @ command line , send output file > character.

assignment.exe > completeoutput.txt


Comments