Simplifying new lines...
-
When I apply new lines, I feel that there's got to be a more easier and byte consuming way of making new lines. I'm new to the programming scene, so much help is appreciated. Instead of applying cout and endl beside every line, is there a more common and better way of doing this? Please offer advice. Thank you. Here's my code:
// Lyrics.cpp : Displaying Lyrics. // Steve Baker #include "stdafx.h" #include using namespace std; int _tmain(int argc, _TCHAR* argv[]) { cout << "'Gone Crazy'" << endl; cout << "by Alan Jackson" << endl; cout << endl; cout << "Here I am all alone again tonight" << endl; cout << "In this old empty house" << endl; cout << "It's hard to learn what you don't think you need" << endl; cout << "You can't live without" << endl; cout << "Never leave the sound of the telephone" << endl; cout << "But ever since you left" << endl; cout << "I've been gone" << endl; cout << "Gone carzy, goin' out of my mind" << endl; cout << "I've asked myself the reasons," << endl; cout << "at least least thousand times," << endl; cout << endl; cout << "Press the Enter key to continue..."; cin.ignore(99,'\n'); return 0; }
-
When I apply new lines, I feel that there's got to be a more easier and byte consuming way of making new lines. I'm new to the programming scene, so much help is appreciated. Instead of applying cout and endl beside every line, is there a more common and better way of doing this? Please offer advice. Thank you. Here's my code:
// Lyrics.cpp : Displaying Lyrics. // Steve Baker #include "stdafx.h" #include using namespace std; int _tmain(int argc, _TCHAR* argv[]) { cout << "'Gone Crazy'" << endl; cout << "by Alan Jackson" << endl; cout << endl; cout << "Here I am all alone again tonight" << endl; cout << "In this old empty house" << endl; cout << "It's hard to learn what you don't think you need" << endl; cout << "You can't live without" << endl; cout << "Never leave the sound of the telephone" << endl; cout << "But ever since you left" << endl; cout << "I've been gone" << endl; cout << "Gone carzy, goin' out of my mind" << endl; cout << "I've asked myself the reasons," << endl; cout << "at least least thousand times," << endl; cout << endl; cout << "Press the Enter key to continue..."; cin.ignore(99,'\n'); return 0; }
-
put the text in a file. read each line of the file in a loop and spit it out onto the console with cout. Much less typing ;)
-
I need to print all my lines on one paper (hw assignment). So I don't think putting the text in a file is optional at the moment. I remember my professor giving shortcuts but forgot what he did. Any ideas?
Then how about... Type one line like this:
cout << "" << endl;
Select the line, Ctrl-C to copy to clipboard, Ctrl-V to copy it a couple hundred times. Navigate to the top line and start typing text between the quotes. :beer: MarkMark Salsbery Microsoft MVP - Visual C++ :java:
-
Then how about... Type one line like this:
cout << "" << endl;
Select the line, Ctrl-C to copy to clipboard, Ctrl-V to copy it a couple hundred times. Navigate to the top line and start typing text between the quotes. :beer: MarkMark Salsbery Microsoft MVP - Visual C++ :java:
-
lol I didn't mean that kind of shortcut. But I think I've figured it out, instead of using endl, I now use \n for new line. But what's the difference between endl and \n? Which should I use for this situation?
MoboTech wrote:
But what's the difference between endl and \n?
endl writes a '\n' to the stream AND flushes the stream. You could do cout.flush(); after you've written the lines of text. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
lol I didn't mean that kind of shortcut. But I think I've figured it out, instead of using endl, I now use \n for new line. But what's the difference between endl and \n? Which should I use for this situation?
MoboTech wrote:
But what's the difference between endl and \n?
In a word...caching.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
lol I didn't mean that kind of shortcut. But I think I've figured it out, instead of using endl, I now use \n for new line. But what's the difference between endl and \n? Which should I use for this situation?
-
When I apply new lines, I feel that there's got to be a more easier and byte consuming way of making new lines. I'm new to the programming scene, so much help is appreciated. Instead of applying cout and endl beside every line, is there a more common and better way of doing this? Please offer advice. Thank you. Here's my code:
// Lyrics.cpp : Displaying Lyrics. // Steve Baker #include "stdafx.h" #include using namespace std; int _tmain(int argc, _TCHAR* argv[]) { cout << "'Gone Crazy'" << endl; cout << "by Alan Jackson" << endl; cout << endl; cout << "Here I am all alone again tonight" << endl; cout << "In this old empty house" << endl; cout << "It's hard to learn what you don't think you need" << endl; cout << "You can't live without" << endl; cout << "Never leave the sound of the telephone" << endl; cout << "But ever since you left" << endl; cout << "I've been gone" << endl; cout << "Gone carzy, goin' out of my mind" << endl; cout << "I've asked myself the reasons," << endl; cout << "at least least thousand times," << endl; cout << endl; cout << "Press the Enter key to continue..."; cin.ignore(99,'\n'); return 0; }
// Lyrics.cpp : Displaying Lyrics. // Steve Baker #include "stdafx.h" char* stuff[]= { {"'Gone Crazy'"}, {"by Alan Jackson"}, {""}, {"Here I am all alone again tonight"}, {"In this old empty house"}, {"It's hard to learn what you don't think you need"}, {"You can't live without"}, {"Never leave the sound of the telephone"}, {"But ever since you left"}, {"I've been gone"}, {"Gone carzy, goin' out of my mind"}, {"I've asked myself the reasons,"}, {"at least least thousand times,"}, {""} }; char otherStuff[]={ "\ 'Gone Crazy'\n\ by Alan Jackson\n\ \n\ Here I am all alone again tonight\n\ In this old empty house\n\ It's hard to learn what you don't think you need\n\ You can't live without\n\ Never leave the sound of the telephone\n\ But ever since you left\n\ I've been gone\n\ Gone carzy, goin' out of my mind\n\ I've asked myself the reasons,\n\ at least least thousand times,\n\ \n" }; using namespace std; int _tmain(int argc, _TCHAR* argv[]) { int nCount=(sizeof(stuff)/sizeof(char*)); // One way... for (int i=0;i