Jump to content

Looking To Learn Something


Blue_cow

Recommended Posts

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

  • Replies 63
  • Created
  • Last Reply

Top Posters In This Topic

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? :blink::O:huh:

Share this post


Link to post
Share on other sites

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 by Kamikaze_Badger

Share this post


Link to post
Share on other sites

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×
×
  • Create New...