Archerzz Posted August 5, 2005 Posted August 5, 2005 Well, I know how I thought in my head what I was doing would work and when I actully wrote the program it only takes the first word from the sentance and prints it.. I have an idea of why but I cant really explain. Here is what I did using C++ #include <iostream> #include <string.h> using namespace std; main() { string sent; int x; cout << "Please Enter a Sentance: "; cin >> sent; cout << sent; printf("\n"); system("pause"); return 0; } Share this post Link to post Share on other sites More sharing options...
Kamikaze_Badger Posted August 5, 2005 Posted August 5, 2005 #include <stdio.h> Share this post Link to post Share on other sites More sharing options...
Archerzz Posted August 5, 2005 Posted August 5, 2005 Ok but how do I get it to print the rest of the sentence. Share this post Link to post Share on other sites More sharing options...
Kamikaze_Badger Posted August 5, 2005 Posted August 5, 2005 Wait for markie to detect any bugs in my formatting function, and use his version. Share this post Link to post Share on other sites More sharing options...
markiemrboo Posted August 5, 2005 Posted August 5, 2005 That my friend is C, functions used are from the stdio.h library.EDIT: Now markie, are you going to teach me how to emulate the pass-by-reference operator? EDIT2: Well, here's the algorithm so far. I've probably messed up a few simple things, but the logic is still there. int i; int j = strlen(stringName[]); char formatter(void) { for(i=0,i<j,i++) { if(stringName[i] = "_") { stringName[i] = " " } return void; } 522867[/snapback] Wait for markie to detect any bugs in my formatting function, and use his version. 523002[/snapback] void formatter(char *str) { int j, i; j = strlen(str); for(i = 0;i < j; i++) { if(str[i] == '_') { str[i] = ' '; } } } But uh.. yeah, I am supposed to be off out for the weekend in about an hour (unless I change my mind at the last minute like I usually do..) sooooo see you all in a few days? Share this post Link to post Share on other sites More sharing options...
Kamikaze_Badger Posted August 5, 2005 Posted August 5, 2005 Wow, I was dangED close... Share this post Link to post Share on other sites More sharing options...
Blue_cow Posted August 5, 2005 Posted August 5, 2005 Did i mention that i started learning C only 2 days ago? This is all so complicated. Anything easy worth trying? Whats the first thing that each of you guys programmed? Share this post Link to post Share on other sites More sharing options...
Kamikaze_Badger Posted August 5, 2005 Posted August 5, 2005 (edited) VERY first for me was a Fahrenheit to Celsius converter (dang YOU C++ FOR DUMMIES!). Try messing around with displaying, reading, and re-displaying variables some more. And, do some typecasting. Edited August 5, 2005 by Kamikaze_Badger Share this post Link to post Share on other sites More sharing options...
CNUco2007 Posted August 5, 2005 Posted August 5, 2005 I have used a lot of different language books for my coding classes back in college, and I have to say that Deitel books are very good. If you're doing C++, Deitel + Deitel's "How to Program C++" is the best programming book I have ever read. In this day and age though, you can get pretty much anything you need online (read: free). 521510[/snapback] I agree, that is an excellent book. i used it in my CPSC 230 class (C++). In fact i think i still have that book from my Freshman Year. (im in my 3rd yr) Share this post Link to post Share on other sites More sharing options...
Blue_cow Posted August 5, 2005 Posted August 5, 2005 heh jeez i feel young. You guys are talking about college and stuff, hell, im only going into my second year of high school. Share this post Link to post Share on other sites More sharing options...
Mangar Posted August 5, 2005 Posted August 5, 2005 If you want to earn a big salary... try becoming an expert in Oracle SQL-plus or ABAP for SAP. You can easily command salaries over 100,000.00 per year B:) Share this post Link to post Share on other sites More sharing options...
Archerzz Posted August 5, 2005 Posted August 5, 2005 the first thing i programed no matter what the language was the hello world program Share this post Link to post Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now