Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Help with C++

Name: Anonymous 2006-04-23 7:29

Hey people. I'm a physics student trying to teach myself C++ since my college doesn't offer it. As I go along the book, I try to test and implement features to try and figure out how they work. So far, so good. But now I'm trying to understand how strings of characters work, and I got the following problem.

I wrote the follow program:
#include <iostream>
using std::cout;

int catprint(char string[12])
{
int n = 0;
  while()
  {
    if(string[n]==0) break;
    cout << string[n];
    n++;
  }
 
  return n;
}

int main()
{
  char hello[12] = {'H','e','l','l','o',' ','W','o','r','l','d',0};
  int finalcount;
 
  finalcount = catprint(string[]);
  cout << "\Number of characters in string: " << finalcount << ".\n";
  cout << "Next char: " << hello[finalcount+1];
 
  return 0;
}

Name: Anonymous 2009-09-05 17:09

[/rem]

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List