 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
ashmangat@yahoo.com Guest
|
Posted: Mon Nov 21, 2005 2:02 am Post subject: Need Help, Can you find the error??? |
|
|
Hi!
now on the chapter "string-class" My assignment is below Word Counter:
Write a function that accepts a pointer to a C-String as an argument
and returns the number of words contained in the string. For instance,
if the string argument is "Four score and seven years ago" the function
should return the number 6. Demonstrate the function in a program that
asks the user to input a string and then passes it to the function. The
number of words
in the string should be displayed on the screen.It should also display
the average number of letters in each word.
Here is the begining of my program
I am getting two errors: LNK2001: unresolved external symbol "char
__cdecl wordCount(char)" (?wordCount@@YADD@Z)
Debug/1.exe : fatal error LNK1120: 1 unresolved externals
--------------------------------------------------------------------------------------------
#include <iostream>
#include <string>
#include <iomanip>
#include <ctype.h>
using namespace std;
char wordCount(char );
int main()
{
char cstring[81];
cout << "nEnter a string, 80 or fewer characters:n";
cin.getline(cstring, 81);
cout << "nThe number of words in that string: ";
cout << wordCount(cstring[81]) << endl;
return 0;
}
char wordCount(char cstring[81])
{
int index = 0;
int word = 0;
while (cstring[index] != ' ')
{
if (isspace(cstring[index]))
{
while (isspace(cstring[index]))
{
index++;
}
}
if (isalnum(cstring[index]))
{
word++; //we must be in a word
while(islower(cstring[index]))
{
word++;
}
}
index++;
}
return cstring[word];
}
---------------------------------------------------------------------------
can anyone find the error and perhaps make a suggestion to fix it.
------
Ash
|
|
| Back to top |
|
 |
Jim Langston Guest
|
Posted: Mon Nov 21, 2005 2:17 am Post subject: Re: Need Help, Can you find the error??? |
|
|
<ashmangat (AT) yahoo (DOT) com> wrote
Hi!
now on the chapter "string-class" My assignment is below Word Counter:
Write a function that accepts a pointer to a C-String as an argument
and returns the number of words contained in the string. For instance,
if the string argument is "Four score and seven years ago" the function
should return the number 6. Demonstrate the function in a program that
asks the user to input a string and then passes it to the function. The
number of words
in the string should be displayed on the screen.It should also display
the average number of letters in each word.
Here is the begining of my program
I am getting two errors: LNK2001: unresolved external symbol "char
__cdecl wordCount(char)" (?wordCount@@YADD@Z)
Debug/1.exe : fatal error LNK1120: 1 unresolved externals
--------------------------------------------------------------------------------------------
#include <iostream>
#include <string>
#include <iomanip>
#include <ctype.h>
using namespace std;
char wordCount(char );
*** Here you're declaring a function accepting a single character as a
parameter
*** Fix this to match your actual function below.
int main()
{
char cstring[81];
cout << "nEnter a string, 80 or fewer characters:n";
cin.getline(cstring, 81);
cout << "nThe number of words in that string: ";
cout << wordCount(cstring[81]) << endl;
return 0;
}
char wordCount(char cstring[81])
*** Here you're declaring a function accepting an array of 81 characters as
a parameter
{
int index = 0;
int word = 0;
while (cstring[index] != ' ')
{
if (isspace(cstring[index]))
{
while (isspace(cstring[index]))
{
index++;
}
}
if (isalnum(cstring[index]))
{
word++; //we must be in a word
while(islower(cstring[index]))
{
word++;
}
}
index++;
}
return cstring[word];
}
|
|
| Back to top |
|
 |
Jim Langston Guest
|
Posted: Mon Nov 21, 2005 2:23 am Post subject: Re: Need Help, Can you find the error??? |
|
|
"Jim Langston" <tazmaster (AT) rocketmail (DOT) com> wrote
| Quote: | ashmangat (AT) yahoo (DOT) com> wrote in message
news:1132538520.388498.160620 (AT) o13g2000cwo (DOT) googlegroups.com...
Hi!
now on the chapter "string-class" My assignment is below Word Counter:
Write a function that accepts a pointer to a C-String as an argument
and returns the number of words contained in the string. For instance,
if the string argument is "Four score and seven years ago" the function
should return the number 6. Demonstrate the function in a program that
asks the user to input a string and then passes it to the function. The
number of words
in the string should be displayed on the screen.It should also display
the average number of letters in each word.
Here is the begining of my program
I am getting two errors: LNK2001: unresolved external symbol "char
__cdecl wordCount(char)" (?wordCount@@YADD@Z)
Debug/1.exe : fatal error LNK1120: 1 unresolved externals
--------------------------------------------------------------------------------------------
#include
#include
#include
#include
using namespace std;
char wordCount(char );
*** Here you're declaring a function accepting a single character as a
parameter
*** Fix this to match your actual function below.
int main()
{
char cstring[81];
cout << "nEnter a string, 80 or fewer characters:n";
cin.getline(cstring, 81);
cout << "nThe number of words in that string: ";
cout << wordCount(cstring[81]) << endl;
|
*** Also, here, why aren't you calling wordCount(cstring) ?
| Quote: | return 0;
}
char wordCount(char cstring[81])
*** Here you're declaring a function accepting an array of 81 characters
as a parameter
{
int index = 0;
int word = 0;
while (cstring[index] != ' ')
{
if (isspace(cstring[index]))
{
while (isspace(cstring[index]))
{
index++;
}
}
if (isalnum(cstring[index]))
{
word++; //we must be in a word
while(islower(cstring[index]))
{
word++;
}
}
index++;
}
return cstring[word];
|
*** What are you trying to return here? Doen't you actually want to return
the number of words? I think your function needs work.
|
|
| Back to top |
|
 |
ashmangat@yahoo.com Guest
|
Posted: Mon Nov 21, 2005 4:59 am Post subject: Re: Need Help, Can you find the error??? |
|
|
no error this time but when it excutes, i'm asked to input a string.
but it stops after the line number of words.
#include <iostream>
#include <string>
#include <iomanip>
#include <ctype.h>
using namespace std;
char wordCount(char []);
int main()
{
char cstring[81];
int index = 0;
cout << "Written by Arshdeep Kaur, Cs102 onlinen";
cout << "nEnter a string, 80 or fewer characters:n";
cin.getline(cstring, 81);
cout << "nThe number of words in that string: ";
wordCount(cstring);
cout << index << endl;
return 0;
}
char wordCount(char cstring[])
{
int index = 0;
int word = 0;
while (cstring[index] != ' ')
{
if (isspace(cstring[index]))
{
while (isspace(cstring[index]))
{
index++;
}
}
if (isalnum(cstring[index]))
{
word++;
while(islower(cstring[index]))
{
word++;
}
while((isalnum(cstring[index])) || ( ispunct(cstring[index])))
{
word++;
}
}
index++;
return index;
}
}
I think there is a problem in my wordCount funtion
|
|
| Back to top |
|
 |
Jim Langston Guest
|
Posted: Mon Nov 21, 2005 5:24 am Post subject: Re: Need Help, Can you find the error??? |
|
|
<ashmangat (AT) yahoo (DOT) com> wrote
| Quote: | no error this time but when it excutes, i'm asked to input a string.
but it stops after the line number of words.
#include
#include
#include
#include
using namespace std;
char wordCount(char []);
int main()
{
char cstring[81];
int index = 0;
cout << "Written by Arshdeep Kaur, Cs102 onlinen";
cout << "nEnter a string, 80 or fewer characters:n";
cin.getline(cstring, 81);
cout << "nThe number of words in that string: ";
wordCount(cstring);
cout << index << endl;
return 0;
}
char wordCount(char cstring[])
{
int index = 0;
int word = 0;
while (cstring[index] != ' ')
{
if (isspace(cstring[index]))
{
while (isspace(cstring[index]))
{
index++;
}
}
*** Okay, here you're saying skip over any white space. |
| Quote: | if (isalnum(cstring[index]))
{
word++;
*** Okay, you skipped over white space, have hit a character so words is |
increased.
| Quote: | while(islower(cstring[index]))
{
word++;
*** Ooops, why are you increasing words for characters? Don't you want to |
skip over
*** the rest of the characters in the word? Wouldn't that be index++ ?
| Quote: | }
while((isalnum(cstring[index])) || ( ispunct(cstring[index])))
{
word++;
*** Same here
}
}
index++;
return index;
Why are you returning index? Don't you mean to return word?
}
}
I think there is a problem in my wordCount funtion
|
|
|
| Back to top |
|
 |
Fabio Fracassi Guest
|
Posted: Mon Nov 21, 2005 9:27 am Post subject: Re: Need Help, Can you find the error??? |
|
|
Jim Langston wrote:
| Quote: | ashmangat (AT) yahoo (DOT) com> wrote in message
news:1132549158.209292.114750 (AT) g43g2000cwa (DOT) googlegroups.com...
no error this time but when it excutes, i'm asked to input a string.
but it stops after the line number of words.
|
(All comments are for ashmangat)
There is also an error in main:
| Quote: | #include
#include
#include
#include
using namespace std;
char wordCount(char []);
int main()
{
char cstring[81];
int index = 0;
cout << "Written by Arshdeep Kaur, Cs102 onlinen";
cout << "nEnter a string, 80 or fewer characters:n";
cin.getline(cstring, 81);
cout << "nThe number of words in that string: ";
wordCount(cstring);
^^^^ |
This should be: index = wordCount(cstring);
The way you do it you just ignore the result of wordCount.
| Quote: | cout << index << endl;
|
If you don't want/need to save the result of wordCount, you could also write
cout << wordCount(cstring) << endl;
instead of the line above, and remove all lines containing index in main.
Note: Just to be clear, index in main and index in wordCount are two
seperate variables, even though they share the name.
Read up on variable scope.
HTH
Fabio
|
|
| Back to top |
|
 |
ashmangat@yahoo.com Guest
|
Posted: Tue Nov 22, 2005 1:02 am Post subject: Re: Need Help, Can you find the error??? |
|
|
Yay it works
Here is the working code
#include <iostream>
#include <string>
#include <iomanip>
#include <ctype.h>
using namespace std;
int wordCount(char []);
int main()
{
char cstring[81];
int index ;
cout << "Written by Arshdeep Kaur, Cs102 onlinen";
cout << "nEnter a string, 80 or fewer characters:n";
cin.getline(cstring, 81);
cout << "nThe number of words in that string: ";
index = wordCount(cstring);
cout << index << endl;
return 0;
}
int wordCount(char cstring[])
{
int index = 0;
int word = 0;
while (cstring[index] != ' ')
{
if (isspace(cstring[index]))
{
while (isspace(cstring[index]))
{
index++;
}
}
if (isalnum(cstring[index]))
{
word++;
while(islower(cstring[index]))
{
index++;
}
while((isalnum(cstring[index])) || ( ispunct(cstring[index])))
{
index++;
}
}
index++;
}
return word;
}
***Now I just need to find the average number in each word, haven't yet
figured out how to do that.
Thanks
---------
Ash
|
|
| Back to top |
|
 |
ashmangat@yahoo.com Guest
|
Posted: Tue Nov 22, 2005 1:57 am Post subject: Re: Need Help, Can you find the error??? |
|
|
#include <iostream>
#include <string>
#include <iomanip>
#include <ctype.h>
#include <stdlib.h>
using namespace std;
void avgg(char[]);
int wordCount(char []);
int main()
{
char cstring[81];
int index;
cout << "Written by Arshdeep Kaur, Cs102 onlinen";
cout << "nEnter a string, 80 or fewer characters:n";
cin.getline(cstring, 81);
cout << "nThe number of words in that string: ";
index = wordCount(cstring);
cout << index << endl;
avgg(cstring);
return 0;
}
int wordCount(char cstring[])
{
int index = 0;
int word = 0;
while (cstring[index] != ' ')
{
if (isspace(cstring[index]))
{
while (isspace(cstring[index]))
{
index++;
}
}
if (isalnum(cstring[index]))
{
word++;
while(islower(cstring[index]))
{
index++;
}
while((isalnum(cstring[index])) || ( ispunct(cstring[index])))
{
index++;
}
}
index++;
}
return word;
}
void avgg( char cstring[])
{
int index = 0;
float avg = 0.0;
int word = 0;
while (cstring[index] != ' ')
{
if (isspace(cstring[index]))
{
while (isspace(cstring[index]))
{
word++;
}
}
if (isalnum(cstring[index]))
{
word++;
while(islower(cstring[index]))
{
index++;
}
while((isalnum(cstring[index])) || ( ispunct(cstring[index])))
{
index++;
}
}
index++;
}
float Total = 0.0;
Total += word;
avg = (Total / index);
cout << "Average: " << fixed << showpoint << setprecision(2) << avg
<< endl;
}
****I am getting avg like 0.02, 0.04
****Can anyone figure out the problem
|
|
| Back to top |
|
 |
Jim Langston Guest
|
Posted: Tue Nov 22, 2005 6:05 am Post subject: Re: Need Help, Can you find the error??? |
|
|
<ashmangat (AT) yahoo (DOT) com> wrote
| Quote: | #include
#include
#include
#include
#include
using namespace std;
void avgg(char[]);
int wordCount(char []);
int main()
{
char cstring[81];
int index;
cout << "Written by Arshdeep Kaur, Cs102 onlinen";
cout << "nEnter a string, 80 or fewer characters:n";
cin.getline(cstring, 81);
cout << "nThe number of words in that string: ";
index = wordCount(cstring);
cout << index << endl;
avgg(cstring);
return 0;
}
int wordCount(char cstring[])
{
int index = 0;
int word = 0;
while (cstring[index] != ' ')
{
if (isspace(cstring[index]))
{
** This if is totally unneccesary. If it isn't a space the while will never |
** be executed. Get rid of the if (isspace(... and just keep the while
(isspace(...
| Quote: | while (isspace(cstring[index]))
{
index++;
}
}
if (isalnum(cstring[index]))
{
word++;
while(islower(cstring[index]))
{
index++;
}
** Why are you passing over lowercase chars? Won't the isalnum also pass |
them over?
** I believe you can get rid of the while(islower(... altogether
| Quote: | while((isalnum(cstring[index])) || ( ispunct(cstring[index])))
{
index++;
}
}
index++;
}
return word;
}
void avgg( char cstring[])
{
int index = 0;
float avg = 0.0;
int word = 0;
while (cstring[index] != ' ')
{
if (isspace(cstring[index]))
{
** Same as in previous funcion
while (isspace(cstring[index]))
{
word++;
** Are you sure you want to do this? Why are you increasing the word count |
** for every space? Don't you want index++ ?
| Quote: | }
}
if (isalnum(cstring[index]))
{
word++;
while(islower(cstring[index]))
{
index++;
}
** Again, why islower?
while((isalnum(cstring[index])) || ( ispunct(cstring[index])))
{
index++;
}
}
index++;
}
float Total = 0.0;
Total += word;
avg = (Total / index);
** Index here is not the number of alphanumeric characters in the string, |
but the
** total number of characters. This is your second problem. Perhaps create
a new
** variable and increment it every time you find an alphanumberic character.
| Quote: | cout << "Average: " << fixed << showpoint << setprecision(2) << avg
endl;
}
****I am getting avg like 0.02, 0.04
****Can anyone figure out the problem
|
There are design issues (like why make 2 functions that do almost the exact
same thing. The same function should count words and letters, and you are
in fact counting both words and letters in the second function.
|
|
| Back to top |
|
 |
ashmangat@yahoo.com Guest
|
Posted: Thu Nov 24, 2005 7:13 am Post subject: Re: Need Help, Can you find the error??? |
|
|
Runs fine until I input puntuation.
#include <iostream>
#include <string>
#include <iomanip>
#include <cctype>
#include <stdlib.h>
using namespace std;
void avgg(char[]);
int wordCount(char []);
int main()
{
char cstring[81];
cout << "nEnter a string, 80 or fewer characters:n";
cin.getline(cstring, 81);
cout << "nThe number of words in that string: ";
cout <
avgg(cstring);
return 0;
}
int wordCount(char cstring[])
{
int index = 0;
int word = 0;
while (cstring[index] != ' ')
{
if (isspace(cstring[index]))
{
while (isspace(cstring[index]))
{
index++;
}
}
if (isalnum(cstring[index]))
{
word++;
while(islower(cstring[index]))
{
index++;
}
while((isalnum(cstring[index])) || (
ispunct(cstring[index])))
{
index++;
}
}
index++;
}
return word;
}
void avgg( char cstring[])
{
int index = 0;
double avg = 0;
int spaces;
int wordd = 0;
double total = 0.0;
while (cstring[index] != ' ')
{
if (isalnum(cstring[index]))
{ index++;
while(islower(cstring[index]))
{
index++;
}
while((ispunct(cstring[index])))
{
index++;
}
}
if (isspace(cstring[index]))
{
while (isspace(cstring[index]))
{
index++;
}
}
if ((ispunct(cstring[index])))
{
index++;
}
wordd++;
spaces = wordd - 1 ;
total = index-spaces;
avg = total/wordd;
}
cout << "Spaces: " << spaces <<"n"<< "Index: " <<
index << " n"
<<"Total: " << total << endl;
cout << "Average: " << fixed << showpoint <<
setprecision(2) << avg
<< endl;
}
I know my avg function is long, i trying to make it in a way so I can
delete the wordcount function and have only one funtion(avg).
|
|
| Back to top |
|
 |
Mike Wahler Guest
|
Posted: Thu Nov 24, 2005 7:26 pm Post subject: Re: Need Help, Can you find the error??? |
|
|
<ashmangat (AT) yahoo (DOT) com> wrote
| Quote: |
I know my avg function is long, i trying to make it in a way so I can
delete the wordcount function and have only one funtion(avg).
|
The goal should not be to reduce the number of functions,
but the size of functions. Most beginner code has too
few functions, and those few functions are too large.
It's far easier to debug and a small function
than a large one.
-Mike
|
|
| Back to top |
|
 |
ashmangat@yahoo.com Guest
|
Posted: Fri Nov 25, 2005 8:02 am Post subject: Re: Need Help, Can you find the error??? |
|
|
This programes run fine, It'll be better if I have all the cout
statements in main but I don't know how to return more than one
variable from wordCount function.
#include <iostream>
#include <iomanip>
#include <cctype>
#include <stdlib.h>
using namespace std;
int wordCount(char []);
int main()
{
int word=0, avg=0;
char cstring[81];
cout << "nEnter a string, 80 or fewer characters:n";
cin.getline(cstring, 81);
word = wordCount(cstring);
cout << "nThe number of words in that string: ";
cout << word << endl;
cout << "average again" << avg << endl;
return 0;
}
int wordCount(char cstring[])
{
int index = 0;
double avg;
double characters;
int word = 0;
int ff = 0;
int fff = 0;
int add = 0;
while (cstring[index] != ' ')
{
if (isspace(cstring[index]))
{
ff++;
while (isspace(cstring[index]))
{
index++;
}
}
if( ispunct(cstring[index]))
{
fff++;
while(ispunct(cstring[index]))
{
index++;
}
}
if ((isalnum(cstring[index])))
{
word++;
while(isalnum(cstring[index]))
{
index++;
}
}
add++;
}
if( index > 0)
{
cout << "add: " << add << endl;
characters = index-(fff + ff);
avg = (characters / word);
cout << "characters: " << characters << "n" << "Index: " << index
<< "n" << "fff: " << fff << "n" << "ff: " << ff << endl;
cout << "Average: " << fixed << showpoint << setprecision(2) <<
avg << endl;
}
return word; //****I also want to return index and fff so I can
calculate the average in main or a new average function
}
|
|
| Back to top |
|
 |
Karl Heinz Buchegger Guest
|
Posted: Fri Nov 25, 2005 9:58 am Post subject: Re: Need Help, Can you find the error??? |
|
|
"ashmangat (AT) yahoo (DOT) com" wrote:
| Quote: |
This programes run fine, It'll be better if I have all the cout
statements in main but I don't know how to return more than one
variable from wordCount function.
|
One more advice.
If you post to multiple groups, don't do it in the form
of sending the same message to both groups.
Just do a multipost. In a nutshell: specify in the To: field
of your newsreader all groups you want your posting to appear.
In this way we don't have to answer the same message multiple times
and/or readers of comp.lang.c++ would see and know what I wrote
as an answer to the very same question in alt.comp.lang.learn.c-c++
Don't worry. Most readers of comp.lang.c++ read alt.comp.lang.learn.c-c++
also. But it is frustrating to come up with an answer in one group
only to figure out later that somebody else already answered your question
in another group.
--
Karl Heinz Buchegger
[email]kbuchegg (AT) gascad (DOT) at[/email]
|
|
| Back to top |
|
 |
ashmangat@yahoo.com Guest
|
Posted: Sat Nov 26, 2005 6:07 am Post subject: Re: Need Help, Can you find the error??? |
|
|
Thanks for the help My program finally runs perfectly, I shrunk it as
much as possible and simpyfied it as much as possible
Here is My finished code below:
#include <iostream>
#include <iomanip>
#include <cctype>
#include <cstdlib>
using namespace std;
void wordCount(char [], int&, double&, int&);
double get_avg(int, int, double);
int main()
{
int word = 0, Punct = 0;
double AllChar = 0.0;
double avg = 0.0;
char cstring[81];
cout << "Enter a string of 80 or fewer characters" << endl;
cout << "=> ";
cin.getline(cstring, 81);
wordCount(cstring, word, AllChar, Punct);
cout <<"nThe number of words in that string: " << word << endl;
avg = get_avg(word, Punct, AllChar);
cout <<"nAverage number of characters per word: "<< fixed <<
showpoint << setprecision(2) << avg << "n" << endl;
return 0;
}
// wordCount() counts total character, words, and Puctuation
void wordCount(char cstring[],int &word, double &AllChar, int &Punct)
{
int index = 0;
while (cstring[index] != ' ')
{
if ((isspace(cstring[index])) || (
ispunct(cstring[index])))
{
while((isspace(cstring[index])) || (
ispunct(cstring[index])))
{
index++;
}
}
if ((isalnum(cstring[index])) || (ispunct(cstring[index])))
{
word++;
while
((isalnum(cstring[index]))||(ispunct(cstring[index])))
{
index++;
AllChar++; //Counting total printable character(including digits
and Punctuation
if((ispunct(cstring[index])))
{
Punct++; // Counting Punctuation
}
}
}
index++;
}
}
// get_avg() calculates the average number of characters per words
double get_avg(int word,int Punct, double AllChar )
{
double avg = 0.0;
AllChar = AllChar - Punct; // Subtracting Punctuatoin from All the
characters in the string(not including spaces)
avg = (AllChar / word);
return avg;
}
Thanks
----
Ash
|
|
| Back to top |
|
 |
Richard Herring Guest
|
Posted: Fri Dec 02, 2005 2:49 pm Post subject: Re: Need Help, Can you find the error??? |
|
|
In message <1132985224.721808.213620 (AT) g44g2000cwa (DOT) googlegroups.com>,
"ashmangat (AT) yahoo (DOT) com" <ashmangat (AT) yahoo (DOT) com> writes
| Quote: | Thanks for the help My program finally runs perfectly,
|
What happens if someone enters a string of 81 characters?
| Quote: | I shrunk it as
much as possible and simpyfied it as much as possible
Here is My finished code below:
#include <iostream
#include
#include
#include
#include
using namespace std;
void wordCount(char [], int&, double&, int&);
double get_avg(int, int, double);
int main()
{
int word = 0, Punct = 0;
double AllChar = 0.0;
double avg = 0.0;
char cstring[81];
|
string cstring;
| Quote: | cout << "Enter a string of 80 or fewer characters" << endl;
cout << "Enter a string" << endl;
cout << "=> ";
cin.getline(cstring, 81);
|
getline(cin, cstring);
// The remaining changes needed are left as an exercise for the
reader...
| Quote: | wordCount(cstring, word, AllChar, Punct);
cout <<"nThe number of words in that string: " << word << endl;
avg = get_avg(word, Punct, AllChar);
cout <<"nAverage number of characters per word: "<< fixed
showpoint << setprecision(2) << avg << "n" << endl;
return 0;
}
// wordCount() counts total character, words, and Puctuation
void wordCount(char cstring[],int &word, double &AllChar, int &Punct)
{
int index = 0;
while (cstring[index] != ' ')
{
if ((isspace(cstring[index])) || (
ispunct(cstring[index])))
{
while((isspace(cstring[index])) || (
ispunct(cstring[index])))
{
index++;
}
}
if ((isalnum(cstring[index])) || (ispunct(cstring[index])))
{
word++;
while
((isalnum(cstring[index]))||(ispunct(cstring[index])))
{
index++;
AllChar++; //Counting total printable character(including digits
and Punctuation
if((ispunct(cstring[index])))
{
Punct++; // Counting Punctuation
}
}
}
index++;
}
}
// get_avg() calculates the average number of characters per words
double get_avg(int word,int Punct, double AllChar )
{
double avg = 0.0;
AllChar = AllChar - Punct; // Subtracting Punctuatoin from All the
characters in the string(not including spaces)
avg = (AllChar / word);
return avg;
}
Thanks
|
--
Richard Herring
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|