Advertisement
C_Volume2 Internet/ HTML #77532

Mike's Chat v1.0

This is a basic Server/Client Chat made using Winsock and the UDB Protocal. The chat is in Rich Text so it looks just like an AOL chat and it also has Sounds when chatting. If the Client/Server closes the program, the other side gets an error saying so. This is so you don't talk to your self..heh All the client's Nicknames get logged into a ListBox and if they leave the room, their name gets removed from the chat listbox. I also included a "Boot Ip" for the server so he/she can boot someone in the chat that is acting up. Check this example out and RATE it! :PContact me atAIM: Mike3dd

AI

สรุปโดย AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

ซอร์สโค้ด
original-source
Upload
<p>
<b>#include &lt;stdio.h&gt;<br>
#include &lt;fcntl.h&gt;</b><br>
Includes files necassary for the program to work. &quot;stdio.h&quot; for standard 
input/output functions such as printf(), scanf() etc. and &quot;fcntl.h&quot; for file 
handling functions such as fopen()</p>
<p>
<b>int main()</b><br>
<b>{<br>
</b>Declaration of function main().</p>
<p>
<b><br>
char ch;<br>
int nol=0,not=0,nob=0,noc=0;<br>
</b>Variables include number of lines, number of tabs, number of blanks and 
number of characters</p>
<p><br>
<b>FILE *fp;<br>
</b>Declaring a pointer variable for file handling use.</p>
<p>
<b>char name[20];<br>
</b>Declaring a string to use for file name.</p>
<p>
<b>printf(&quot;Enter File Name:&quot;);<br>
</b>Displaying a prompt for user saying &quot;Enter File Name:&quot;</p>
<p>
<b>gets(name);</b><br>
</b>Inputting file name in form of string</p>
<p>
<b>fp=fopen(name,&quot;r&quot;);</b><br>
</b>Opening a file based on filename in write mode (r) and issuing it to pointer 
fp<b><br>
<br>
if(fp==NULL)<br>
{<br>
printf(&quot;\nCannot open file\n&quot;);<br>
goto programend;<br>
}<br>
</b>If file cannot be opened (thus returning fp as NULL) display &quot;Cannot open 
file&quot; and goto end of program which is displayed after file usage. (exit 
function can be used here but that would make things complicated)<b><br>
<br>
while(1)<br>
{<br>
</b>Using an infinite loop, it will keep repeating forever until we make it 
break out of loop.</p>
<p>
<b>ch=fgetc(fp);</b><br>
</b>Character variable we defined earlier in the beginning of main function is 
assigned the value of current character cursor is on (or under consideration in 
other words).<b><br>
<br>
if(ch==EOF) break;<br>
</b>If current character under consideration is End Of File (meaning file's end 
has came), break out of infinite loop thus going to end of program.<b><br>
<br>
noc++;<br>
</b>Passed above conditions, now value number of characters is increased by 1<b><br>
if(ch==' ') nob++;<br>
</b>if current character is space/blank, value number of blanks is increased by 
1<b><br>
if(ch=='\n') nol++;<br>
</b>if current character is new line character, value number of lines is 
increased by 1<b><br>
if(ch=='\t') not++;<br>
</b>if current character is tab character, value number of tabs is increased by 
1<b><br>
}</b></p>
<p><b>fclose(fp);<br>
</b>Close opened file</p>
<p><b>printf(&quot;\nChracters=%d \nBlanks=%d \nTabs=%d \nLines=%d \n&quot;, noc, nob, 
not, nol);<br>
</b>Display our calculations<b><br>
</b>
<p><b>programend:<br>
</b>The point of program end. if anywhere in the program it is said that <b>goto 
programend;</b> the program will jump here.<b><br>
</b>
<p><b>return (0);<br>
</b>Beginners don't need to understand this, for advanced users main function 
returns nothing.</p>
<p>
<b>}</b><br>
</b>Main function closes here.</p>
<p><h3>DO NOT FORGET TO RATE THIS TUTORIAL. ITS EASY, JUST SCROLL DOWN AND YOU'LL SEE SCROLLING BOX</h3></p>
ความคิดเห็นดั้งเดิม (3)
กู้คืนจาก Wayback Machine