|
write a C function that produces a histogram of the number of occurrence of each letter in a character string. your function should be case independent. your function should have two parameters : the first is a pointer to an array of 26 int that holds the histogram; the second is a pointer to a character string. function return the number of letters found in the character string as an integer
|
|
|
|
|
int DestroyedFuture(int* array, char* str) <br />
{<br />
int i;<br />
int j;<br />
int len;<br />
int length;<br />
len = strlen(str);<br />
char c;<br />
length = 0;<br />
for (i = 0; i < len; i++)<br />
{<br />
c = str[i];<br />
c = toupper(c);<br />
for (j = 65; j < 65+26; j++)<br />
{<br />
if (c == j)<br />
{<br />
length++;<br />
array[j-65]++;<br />
}<br />
}<br />
}<br />
return length; <br />
}
It took about 2 minutes to write this code.
I will get flamed for it I know. Heh. I have nothing better to do.
this is this.
|
|
|
|
|
Nice job but that inner for loop is really unnecessary. How about:
int DestroyedFuture( int *array, const char *str )
{
int count = 0,
len = strlen(str);
for (int i = 0; i < len; i++)
{
if (isalpha(str[i]))
{
char c = toupper(str[i]);
array[c - 65]++;
count++;
}
}
return count;
}
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Your subject indicates you need help. What have you done that you need help with? If nothing, you might want to consider changing the subject to "i need you to fix the histogram.plz" instead.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
hi,
My Application had Two child Dialogs, i want these Dialogs should be placed on taskbar when they are minimized...
plz help me
-- modified at 3:01 Friday 23rd September, 2005
|
|
|
|
|
While creating dialog bar, make desktop window as parent , either by using constructor or while creating.
You can get desktop window handle by using GetDesktopWindow()
|
|
|
|
|
When I send a data from one PC to another PC, I want it automatic send back a respond data. I don't know whether got this kind of fuction or not. Can someone tell me...
|
|
|
|
|
jyhhaur wrote:
When I send a data from one PC to another PC
How do you send the data ?? Is it with serial port, through a LAN, a wireless connection or even little animals that bring the data to the computer (if you don't explain, we will need to use our imagination and I have a lot of imagination )
jyhhaur wrote:
I want it automatic send back a respond data
What is 'automatic' ? The computer, without any program running on it should send your little animals back (of course, in case if this was the communication media ).
Sorry, but if you don't provide us with information, we cannot answer your question.
|
|
|
|
|
I send the data through TCP. the 'automatic' is I use a program that I have to send a data through TCP and I want it respond to my data. I just think whether it have something like that or not.....or a function that can write so that it will respond to my data.
|
|
|
|
|
u mean the receiver after getting the data should say, "i got it"??that u've to code urself..;P
V
|
|
|
|
|
Does any one has got the idea where i could find the file dlibtiff.I 'm working on project in which i need to convert tiff to PDF for this I am using
libtiff.lib but when i try to compile i get this error that could not find dlibtiff.lib
No where on NET i v found this
Your help is required...
asifrogers
|
|
|
|
|
|
If I define int a=2; inside a function body which section of the executable file format will contain this information ?
3.what is the vc++ executable file format used on microsoft windows os?
Nice talking to you.
|
|
|
|
|
|
the information will take the form of executable code (rather than static data) and will typically live within the .text section of your exe.
the exe file format on Windows is the Portable Executable.
James
http://www.catch22.net
|
|
|
|
|
If you define int a=2 within a function it will be in local memory, so no section!
Don't try it, just do it!
|
|
|
|
|
How to communicate with an activeX control which has various controls like buttons, edit boxes, combo boxes, etc.
aasstt
|
|
|
|
|
By setting and getting its properties.
(But anyway, your question is not a ... clear one )
SkyWalker
|
|
|
|
|
aasstt wrote:
How to communicate with an activeX control which has various controls like buttons, edit boxes, combo boxes, etc
Surly... so u have some idea of COM/ATL... if not then it going to very difficult way for you.... as you have to understand how Activex work and how to put and get data from it...
any way this link will be benificial for you...
http://www.codeproject.com/atl
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
superb article really for a beginner like me.. thanks a lot. i'd give more than an Excellent vote but i dont find one anyway great yaar
V
|
|
|
|
|
Vivekuniq wrote:
superb article really for a beginner like me..
Which article are you talking about Buddy!!!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
oops i thought i was replying to ur mail !! he he ur COM/ATL for beginners i meant..
V
|
|
|
|
|
hi
how to write an uninstall application that should appear in Add/Remove programs of Control panel.
|
|
|
|
|
use installshield
http://www.codeproject.com/tips/installshield.asp
|
|
|
|
|