0

It's saying I have 6 errors. Need help, please..or a push into the right direction. Thank-you. :)

#include <iostream>
#include <cctype>
using namespace std;

int Len_String(char *);
int CountCapitals(char *);
int CountVowels(char *);
int main()
{
   char msg[] = "Strayer - what a University !";
   char msg2[] = "Programming is a Challenge";
   cout << msg << strlen(msg) << endl;
   cout << msg << Len_String(msg) << endl;
   cout << msg << CountCapitals(msg) << endl;
   cout << msg << CountVowels(msg) << endl;
   cout << msg2 << strlen(msg2) << endl;
   cout << msg2 << Len_String(msg2) << endl;
   cout << msg2 << CountCapitals(msg2) << endl;
   cout << msg2 << CountVowels(msg2) << endl;
   return 0;
}
int Len_String(char *p) 
{
	int line (char *p)

	cout << "Enter a line of characters: " << endl;
	cin.getline()
	
	
   int length;
   int *ch_ptr;
   while (*char_p != '\0')
   {
	 ++length;
	 ++ch_ptr;
   }
   return length;

}//End of Len_String()
int CountCapitals(char *p) 
{
   int length = 0;
   int *ch_ptr;
   cout << "Enter a line of CountCharacters: " <<endl;
   while (*ch_ptr ! = '\0')
   {
	++count;
	++ch_ptr;
   }
}//End of Len_String()

int CountVowels(char *p)   
{ 
int length = 0;
int *ch_ptr;
cout << "Enter a line of CountVowels: " <<endl;
	 while (*ch_ptr ! = '\0')
	 {
	++count;
	++ch_ptr;
	 }
}//End of Len_String()

Edited by WaltP: Added CODE tags -- with all the help about them, how could you miss using them????

5
Contributors
17
Replies
18
Views
7 Years
Discussion Span
Last Post by pinknblu
Featured Replies
  • 1

    [QUOTE=pinknblu;1167382] and it say's: 'ch_p' : undeclared identifier [/QUOTE] So in this piece of code: [code] int Len_String(char *p) { int length = 0; while (*[COLOR="red"]ch_p[/COLOR] !='\0')[/code] Where exactly did you declare ch_p? Read More

  • I guess I didn't every time I try I end up with more errors. Read More

0

Thank-you, I figured that much....will continue to work on it...later.

If anyone else has input..it would be appreciated.

Edited by pinknblu: Wanted to add more words.

0

Thank-you, I figured that much....will continue to work on it...later.

If anyone else has input..it would be appreciated.

Code tags.

[code]

// code here

[/code]

Take the errors one by one. Some are obvious:

int line (char *p)

What's this?

cin.getline()

Where does the data go? Look up getline and see what parameters it requires. Your call must match the spec.

0

okay, I've rewritten it..
still working on it, thank-you for your insight.

Edited by pinknblu: rewritten my response.

0
#include <iostream>
#include <cctype>
using namespace std;

int Len_String(char *);
int CountCapitals(char *);
int CountVowels(char *);
int main()
{
char msg[] = "Strayer - what a University !";
char msg2[] = "Programming is a Challenge";
cout << msg << strlen(msg) << endl;
cout << msg << Len_String(msg) << endl;
cout << msg << CountCapitals(msg) << endl;
cout << msg << CountVowels(msg) << endl;
cout << msg2 << strlen(msg2) << endl;
cout << msg2 << Len_String(msg2) << endl;
cout << msg2 << CountCapitals(msg2) << endl;
cout << msg2 << CountVowels(msg2) << endl;
return 0;
}
int Len_String(char *p) 
{
	
int length = 0;
while (*ch_p !='\0')
{

	++length;
	++ch_p;
}
return length;

}//End of Len_String()

int CountCapitals(char *p) 
{
int length = 0;
int *ch_p;

while (*ch_p ! = '\0')
{
++count;
++ch_p;
}
}//End of Len_String()

int CountVowels(char *p) 
{ 
int length = 0;
int *ch_p;

while (*ch_p ! = '\0')
{
++count;
++ch_p;
}
}//End of Len_String()

I rewrote it...any input would be helpful.....I have two errors now and it say's:
'ch_p' : undeclared identifier

It's causing me a headache, I must say.

Edited by Nick Evan: Fixed code-tags

1

and it say's: 'ch_p' : undeclared identifier

So in this piece of code:

int Len_String(char *p) 
{
	
int length = 0;
while (*ch_p !='\0')

Where exactly did you declare ch_p?

0

Errors:-

1. In function Len_String(char *p) ---- int line (char *p) is useless. Remove it.
2. In function Len_String(char *p) ----*char_p is undefined. Probably it should be *p (typo error)
3. In function CountCapitals(char *p) ---- while (*ch_ptr ! = '\0'). There should be no sapce between ! and =
4. In function CountVowels(char *p) ---- while (*ch_ptr ! = '\0'). There should be no sapce between ! and =

Edited by Luckychap: n/a

0

An updated version, now I have to figure out the "CountVowels" part of my code.
Whomever looks for this problem, I hope this helps you...I see most respondent here don't help, and when u comment on that they give you negative reviews. To those that are here to really help, that aren't smart AlEc's... thank-you.


My code currently:

#include <iostream>
#include <cctype>
using namespace std;

int Len_String(char *);
int CountCapitals(char *);
int CountVowels(char *);
int main()
{
char msg[] = "Strayer - what a University !";
char msg2[] = "Programming is a Challenge";
cout << msg << strlen(msg) << endl;
cout << msg << Len_String(msg) << endl;
cout << msg << CountCapitals(msg) << endl;
cout << msg << CountVowels(msg) << endl;
cout << msg2 << strlen(msg2) << endl;
cout << msg2 << Len_String(msg2) << endl;
cout << msg2 << CountCapitals(msg2) << endl;
cout << msg2 << CountVowels(msg2) << endl;
return 0;
}
int Len_String(char* ch_ptr) 
{
int length = 0;
while (*ch_ptr != '\0')
{
	++length;
	++ch_ptr;
}
return length;

}//End of Len_String()

int CountCapitals(char* ch_ptr) 
{
int upper_count = 0;
while (*ch_ptr != '\0')
{
 isupper(*ch_ptr);
{
 ++upper_count;
}
return upper_count;
   
}// End of CountCapitals()

int CountVowels(char* ch_ptr) 
{
int CountVowels = 0;
while (*ch_ptr != '\0')
{
if(ch_ptr =[a] || ch_ptr = [e] || ch_ptr = [i] || ch_ptr = [o]|| ch_ptr = [u])
}
++count;
++vowels;
{

return CountVowels();

}

Edited by Nick Evan: Fixed closing tags (again). It's [/code] not /code]

0

Errors:-

1. In function Len_String(char *p) ---- int line (char *p) is useless. Remove it.
2. In function Len_String(char *p) ----*char_p is undefined. Probably it should be *p (typo error)
3. In function CountCapitals(char *p) ---- while (*ch_ptr ! = '\0'). There should be no sapce between ! and =
4. In function CountVowels(char *p) ---- while (*ch_ptr ! = '\0'). There should be no sapce between ! and =

Thank-you.

0

Whomever looks for this problem, I hope this helps you...I see most respondent here don't help, and when u comment on that they give you negative reviews. To those that are here to really help, that aren't smart AlEc's... thank-you.

I'm guessing "most repondents" is referring to me. Since the OP decided to bring it up in an unrelated thread, I'll link it. People can decide for themselves whether they want to help this guy.

http://www.daniweb.com/forums/thread269341.html

0

Luckychap
Thank-you very much...It was a typo.
ch_p
is supposed to be ch_ptr
I've re-written it....
Will post a reprise of my program....today.

0
#include <iostream>
#include <cctype>
using namespace std;
int Len_String(char *);
int CountCapitals(char *);
int CountVowels(char *);
int main()
{
char msg[] = "Strayer - what a University !";
char msg2[] = "Programming is a Challenge";
cout << msg << strlen(msg) << endl;
cout << msg << Len_String(msg) << endl;
cout << msg << CountCapitals(msg) << endl;
cout << msg << CountVowels(msg) << endl;
cout << msg2 << strlen(msg2) << endl;
cout << msg2 << Len_String(msg2) << endl;
cout << msg2 << CountCapitals(msg2) << endl;
cout << msg2 << CountVowels(msg2) << endl;
return 0;
}
int Len_String(char* ch_ptr) 
{
int length = 0;
while (*ch_ptr != '\0')
{
    ++length;
    ++ch_ptr;
}
return length;

}//End of Len_String()

int CountCapitals(char* ch_ptr) 
{
   int upper_count = 0;
   while (*ch_ptr != '\0')
   {
      isupper(*ch_ptr);
      {
         ++upper_count;
      }
   return upper_count;

   }  // End of CountCapitals()
}
int CountVowels(char* ch_ptr) 
{
int vowel_count = 0;
while (*ch_ptr != '\0')
{
 if ((*ch_ptr) == 'a'||(*ch_ptr) == 'A')
 ++vowel_count;
 else if ((*ch_ptr) == 'e'||(*ch_ptr) == 'E')
 ++vowel_count;
 else if ((*ch_ptr) == 'i'||(*ch_ptr) == 'I')
 ++vowel_count;
 else if ((*ch_ptr) == 'o'||(*ch_ptr) == 'O')
 ++vowel_count;
 else if ((*ch_ptr) == 'u'||(*ch_ptr) == 'U')
 ++vowel_count;
 else if ((*ch_ptr) == 'y'||(*ch_ptr) == 'Y')
 ++vowel_count;
++ch_ptr;
   }
return vowel_count;
}

SOLVED IT....The program succeeds but the debugging process takes a minute to execute.

Edited by mike_2000_17: Fixed formatting

0

start quote:

int CountCapitals(char* ch_ptr) 
{
   int upper_count = 0;
   while (*ch_ptr != '\0')
   {
      isupper(*ch_ptr);
      {
         ++upper_count;
      }
   return upper_count;

   }  // End of CountCapitals()
}

SOLVED IT....The program succeeds but the debugging process takes a minute to execute.

Not solved I guess so. Look at the above function, its not doing what is suppose to do(no increment of ch_ptr).

By the way what is 'debugging process' and how it is executed?

Edited by mike_2000_17: Fixed formatting

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.