Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Program to cipher a text, new thread, fresh one Date: Sat, 31 Oct 2015 13:18:13 -0700 Organization: None to speak of Lines: 36 Message-ID: References: <8465675b-8538-4031-a5b7-d5ddba34197d@googlegroups.com> <2990d9c4-38b6-41f4-8504-bc95e8eb16ea@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="20834"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Xzf7CQVJFzfEREPGany0P" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:RKOr8GuijHF5GayCrbUm3/HqaRk= sha1:nnS2642eohxZ/nDvIGwbYakCGNA= Xref: csiph.com comp.lang.c:74485 Alla _ writes: >> If fgets() succeeds (and returns a non-NULL value), you call new_text(). >> >> If it fails (either because of an input error or because the user >> provided no input), you do nothing. >> >> Is that what you want? >> >> You print an error message if the user didn't provide a proper >> command-line argument. Do you also want to print an error message if >> the user didn't enter a message? I wrote the above text. You didn't include the attribution line that would have indicated that. (I understand that Google Groups makes it difficult to trim quoted text properly.) > Everything in the main function, especially after your suggestions > on efficiency, is now the way it should be. Even before the main one > worked the way it was set in the task. > Below I am posting the first program before I have made changes to it, > and this one produces the correct result only for the first word in the > entered message; but fails to compute correctly the middle word, because > index is wrapping around in a wrong way, not based on alphabetical > characters of the entered message. In both versions, you do nothing if printf returns NULL (i.e., if the user doesn't provide any input). Is that your intent? (In my opinion it would be appropriate to print an error message.) [...] -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"