Answer to Question #295953 in C++ for Baba

Question #295953

WAP to count number of Characters in a word using pointer to string.

1
Expert's answer
2022-02-10T07:12:41-0500
#include<iostream>
using namespace std;
int main() {
  char str[20], *pt;
  int i = 0;
  cout << "Pointer Example Program : Count the Number of Characters in a word \n";
  cout << "Enter Any string [below 20 chars] : ";
  cin >>str;
  pt = str;
  while (*pt != '\0') {
    i++;
    pt++;
  }
  cout << "Length of String : "<< i;


  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog