#AsuultSambar :

ASUULT.NET - МОНГОЛ УЛС МАНДАН БАДРАГ!
It is currently Oct.16.18 2:36 am

All times are UTC+09:00




Post new topic  Reply to topic  [ 876 posts ]  Go to page Previous 130 31 32 33 34 Next
Author Message
 Post subject: Re: C++
PostPosted: Oct.20.11 8:28 pm 
Offline
Supsta Asuult Sambar
User avatar

Joined: May.21.02 11:17 pm
Posts: 15365
davhar * ail = neg ortson dahi ailiin too garad irne sht
teged oloh ailiin dugara ortson dahi aildaa huvaagad buhel hesgigi n avad 1 iig nemchul ortsniih n dugaar, uldegdliig neg davhar dahi ailiin toodoo huvaaval davhar n garna

_________________
¯\_(ツ)_/¯


Top
   
 Post subject: Re: C++
PostPosted: Oct.20.11 8:44 pm 
Offline
Өсөх Ирээдvйтэй Гишvvн
Өсөх Ирээдvйтэй Гишvvн
User avatar

Joined: Jun.29.10 9:45 pm
Posts: 9
haalganii nomer/davhar dahi ailiin too=buhel heseg+1 davhar ni garna
haalganii nomer/davhar dahi ailiin too= huvaagaad garsan uldegdel ni heddeh haalga boloh ni
davhar dahi ailiin too*davhariin too=ortson doh ailiin too hervee ortson doh ailiin toonoos ih bval daraagiin ortsruu shiljine geh meteer l yavah bh gj bodood bgaam??? :think:
yaj eniigee C++ dr bichhuu?... :crysad: HELP PLS... :wink:


Top
   
 Post subject: Re: C++
PostPosted: Oct.20.11 9:07 pm 
Offline
Supsta Asuult Sambar
User avatar

Joined: May.21.02 11:17 pm
Posts: 15365
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
int x, y, z, d, e, orts, davhar;
scanf("%d%d%d%d", &x, &y, &z, &e);
d=y*z;
if (e>d)
{

orts=e/d+1;
davhar=(e%d)/x;

}
else
{
orts=1;
davhar=e/x;
}
printf("%d\n", orts);
printf("%d", davhar);
system("PAUSE");
return 0;
}

_________________
¯\_(ツ)_/¯


Top
   
 Post subject: Re: C++
PostPosted: Oct.20.11 9:40 pm 
Offline
Өсөх Ирээдvйтэй Гишvvн
Өсөх Ирээдvйтэй Гишvvн
User avatar

Joined: Jun.29.10 9:45 pm
Posts: 9
bayarlalaa gehdee ajilluulah gheer uchiriig ni oldogguee hov hooson har yum l garch ireed bhiin eniig ni yahuu???


Top
   
 Post subject: Re: C++
PostPosted: Oct.21.11 2:35 am 
Offline
Асуулт Самбарын Хvндэт Харуул

Joined: Jul.31.03 2:44 pm
Posts: 6275
Location: in ma imagination
Хүүхдүүд С++ аа сурсаар л байна уу


Top
   
 Post subject: Re: C++
PostPosted: Oct.30.11 10:08 pm 
Offline
Даяар Дурсагдах Гишvvн
Даяар Дурсагдах Гишvvн
User avatar

Joined: Nov.09.10 4:49 pm
Posts: 116
Location: Cyber World
Goe hicheel bnuu ?
surahiig husej bna


Top
   
 Post subject: Re: C++
PostPosted: Nov.02.11 2:33 am 
Offline
Гялалзан Бусдын Нvд Гялбуулагч
Гялалзан Бусдын Нvд Гялбуулагч
User avatar

Joined: Apr.18.10 6:54 am
Posts: 45
Location: UB Mongolia
#define INVALID_SET_FILE_POINTER ((DWORD)-1)

typedef struct root_Entries
{
BYTE short_FileName[11];
BYTE fileAttributes;
BYTE reserved;
BYTE createTime_ms;
WORD createTime;
WORD createDate;
WORD accessedDate;
WORD clusterNumber_High;
WORD modifiedTime;
WORD modifiedDate;
WORD firstClusterAddress_FAT12;
DWORD sizeofFile;
} root;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;

// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL,
::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}
else
{
DWORD dwFilePointer;
DWORD dwBytesRead;
root stRoot;
BYTE byteRoot[512];
memset(&byteRoot, 0, 512);

HANDLE hFloppy = NULL;
hFloppy = CreateFile("\\\\.\\A:", // Floppy drive to open
GENERIC_READ, // Access mode
FILE_SHARE_READ, // Share Mode
NULL, // Security Descriptor
OPEN_EXISTING, // How to create
0, // File attributes
NULL); // Handle to template
if(hFloppy != NULL)
{
dwFilePointer = SetFilePointer(hFloppy,
(512 * 19), NULL, FILE_BEGIN);
// Test for failure
if (dwFilePointer != INVALID_SET_FILE_POINTER)
{
int iSector = 19;
BOOL bNoEntry = FALSE;
// Iterate through root directory sectors
do
{
if (!ReadFile(hFloppy, byteRoot, 512,
&dwBytesRead, NULL))
{
printf("Error in Reading Root Entry.\n");
}
else
{
BYTE *pByteRoot = byteRoot;
// Iterate through 32 byte entries
for(int i = 0; i < (512/32); i++)
{
memcpy(&stRoot, pByteRoot, 32);

// No entry beyond this used.
if(stRoot.short_FileName[0] == 0x00)
{
// Stop iteration
bNoEntry = TRUE;
break;
}
else
{
// This if loops checks for file deletion
// status
if(stRoot.short_FileName[0] == 0xE5)
{
printf("First character of file after
deletion :0x%x\n",
stRoot.short_FileName[0]);
printf("File status: Deleted.\n");
}

printf("File Name : %s\n",
: stRoot.short_
: FileName);
if(stRoot.fileAttributes & 0x01)
printf("File Attribute : Read Only File\n");
if(stRoot.fileAttributes & 0x02)
printf("File Attribute : Hidden File\n");
if(stRoot.fileAttributes & 0x04)
printf("File Attribute : System File\n");
if(stRoot.fileAttributes & 0x08)
printf("File Attribute : Volume Label\n");
if(stRoot.fileAttributes & 0x0f)
printf("File Attribute : Long File Name\n");
if(stRoot.fileAttributes & 0x10)
printf("File Attribute : Directory\n");
if(stRoot.fileAttributes & 0x20)
printf("File Attribute : Archive\n");

WORD nYear = (stRoot.createDate >> 9);
WORD nMonth = (stRoot.createDate << 7);
nMonth = nMonth >> 12;
WORD nDay = (stRoot.createDate << 11);
nDay = nDay >> 11;

printf("Create Date : %d/%d/%d\n", nDay,
: nMonth, (nYear+1980));

nYear = (stRoot.modifiedDate >> 9);
nMonth = (stRoot.modifiedDate << 7);
nMonth = nMonth >> 12;
nDay = (stRoot.modifiedDate << 11);
nDay = nDay >> 11;

printf("Modification Date : %d/%d/%d\n",
: nDay, nMonth,
: (nYear+1980));

nYear = (stRoot.accessedDate >> 9);
nMonth = (stRoot.accessedDate << 7);
nMonth = nMonth >> 12;
nDay = (stRoot.accessedDate << 11);
nDay = nDay >> 11;

printf("Accessed Date : %d/%d/%d\n",
: nDay, nMonth,
: (nYear+1980));

printf("Start Cluster Address: %d\n",
stRoot.firstClusterAddress_FAT12);
printf("File Size : %d bytes\n",
: stRoot.
:sizeofFile);
pByteRoot += 32;
} // End of else
}

if(bNoEntry)
break;
else
{
iSector += 1;
}
}
} while(iSector <= 33);
}

CloseHandle(hFloppy);
}
}

return nRetCode;
}
ene code-iin aldaag zasaad uguuch guij bna


Top
   
PostPosted: Dec.08.11 1:12 pm 
Offline
Шинэков Гишvvн
Шинэков Гишvvн

Joined: Dec.08.11 12:59 pm
Posts: 2
Hi all
C++ gaigvi meddeg hvn baival neg jijken project bichij tus bolooch bi 20.000 ogii.
yaraltai. hervee chadah hvn bwl bubaarai@yahoo.com ene idg add hiigeed messengert ym bicheere yaraltai shuu.


Top
   
 Post subject: Re: C++
PostPosted: Dec.08.11 1:49 pm 
Offline
Шинэков Гишvvн
Шинэков Гишvvн

Joined: Dec.08.11 12:59 pm
Posts: 2
pls help guys. C++ gaigvi meddeg hvnd bol mash amarhan halit neg jijken ym bicheel boloo bi gomdoohgvi shv. golni yararltai tus bolooch pls


Top
   
 Post subject: Re: C++
PostPosted: Dec.19.11 12:56 am 
Offline
Эрхэм Гишvvн
Эрхэм Гишvvн

Joined: Jun.05.09 6:31 pm
Posts: 37
Microsoft visual studio 2010 deer #graphic.h duudhaar cannot include graphic.h geed bnaa. yaj graphic gorimiin library-g oruulahuu. help me all. yaraltai shvv. bie daalta hiij uguh heregtei bn.... pls all


Top
   
 Post subject: Re: C++
PostPosted: Dec.19.11 1:08 am 
Offline
Supsta Asuult Sambar
User avatar

Joined: May.21.02 11:17 pm
Posts: 15365
graphic.h ugasa bdgu bha

_________________
¯\_(ツ)_/¯


Top
   
 Post subject: Re: C++
PostPosted: Dec.19.11 11:11 pm 
Offline
Асуулт Самбарын Хvндэт Харуул

Joined: Jul.31.03 2:44 pm
Posts: 6275
Location: in ma imagination
.Net зөвхөн C# байдаг юм байх гэж бодсон чинь, C++ бас байдаг юм уу?


Top
   
 Post subject: Re: C++
PostPosted: Dec.20.11 1:38 am 
Offline
Хvнд Гишvvн
Хvнд Гишvvн
User avatar

Joined: Jun.09.09 3:50 pm
Posts: 153
Location: 76H l*l*R
[code]#include <stdio.h>
#include <conio.h>

main()

{
int a,b;
printf("5 hurtelh orontoi duriin too oruulna uu: ");
scanf("%d",&a);
printf("tanii oruulsan toog ugeer ilerhiilvel: \n");

if(a/1000%10==0)
{
b=a/10000;
switch (b)
{
case 1: {printf("arvan myanga ");break;}
case 2: {printf("horin myanga ");break;}
case 3: {printf("guchin myanga ");break;}
case 4: {printf("duchin myanga ");break;}
case 5: {printf("tavin myanga ");break;}
case 6: {printf("jaran myanga ");break;}
case 7: {printf("dalan myanga ");break;}
case 8: {printf("nayan myanga ");break;}
case 9: {printf("eren myanga s");break;}
}
}
else
{
b=a/10000;
switch(b)
{
case 1: {printf("arvan ");break;}
case 2: {printf("horin ");break;}
case 3: {printf("guchin ");break;}
case 4: {printf("duchin ");break;}
case 5: {printf("tavin ");break;}
case 6: {printf("jaran ");break;}
case 7: {printf("dalan ");break;}
case 8: {printf("nayan ");break;}
case 9: {printf("eren ");break;}
}
b=a/1000%10;
switch(b)
{
case 1: {printf("negen myanga ");break;}
case 2: {printf("hoyor myanga ");break;}
case 3: {printf("gurvan myanga ");break;}
case 4: {printf("durvun myanga ");break;}
case 5: {printf("tavan myanga ");break;}
case 6: {printf("zurgaan myanga ");break;}
case 7: {printf("doloon myanga ");break;}
case 8: {printf("naiman myanga ");break;}
case 9: {printf("esen myanga ");break;}
}
}

if(a%100==0)
{
b=a/100%10;
switch(b)
{
case 1: {printf("neg zuu");break;}
case 2: {printf("hoyor zuu");break;}
case 3: {printf("gurvan zuu");break;}
case 4: {printf("durvun zuu");break;}
case 5: {printf("tavan zuu");break;}
case 6: {printf("zurgaan zuu");break;}
case 7: {printf("doloon zuu");break;}
case 8: {printf("naiman zuu");break;}
case 9: {printf("esen zuu");break;}
}
}
else
{
b=a/100%10;
switch(b)
{
case 1: {printf("neg zuun ");break;}
case 2: {printf("hoyor zuun ");break;}
case 3: {printf("gurvan zuun ");break;}
case 4: {printf("durvun zuun ");break;}
case 5: {printf("tavan zuun ");break;}
case 6: {printf("zurgaan zuun ");break;}
case 7: {printf("doloon zuun ");break;}
case 8: {printf("naiman zuun ");break;}
case 9: {printf("esen zuun ");break;}
}

if(a%10==0)
{
b=a/10%10;
switch(b)
{
case 1: {printf("arav ");break;}
case 2: {printf("hori ");break;}
case 3: {printf("guch ");break;}
case 4: {printf("duch ");break;}
case 5: {printf("tavi ");break;}
case 6: {printf("jar ");break;}
case 7: {printf("dal ");break;}
case 8: {printf("nay ");break;}
case 9: {printf("er ");break;}
}
}
else
{
b=a/10%10;
switch(b)
{
case 1: {printf("arvan ");break;}
case 2: {printf("horin ");break;}
case 3: {printf("guchin ");break;}
case 4: {printf("duchin ");break;}
case 5: {printf("tavin ");break;}
case 6: {printf("jaran ");break;}
case 7: {printf("dalan ");break;}
case 8: {printf("nayan ");break;}
case 9: {printf("eren ");break;}
}

}

switch(a%10)
{
case 1: {printf("neg ");break;}
case 2: {printf("hoyor ");break;}
case 3: {printf("gurav");break;}
case 4: {printf("duruv ");break;}
case 5: {printf("tav ");break;}
case 6: {printf("zurgaa ");break;}
case 7: {printf("doloo ");break;}
case 8: {printf("naim ");break;}
case 9: {printf("es");break;}
}
}

getch();
return 0;


}

Ene programiig C-giin ymar program der bichsin bol?


Top
   
 Post subject: Re: C++
PostPosted: Dec.22.11 11:14 am 
Offline
Asuult Precious Member
User avatar

Joined: Feb.07.09 9:44 pm
Posts: 4767
Location: Ulaanbaatar Mongolia
энэ бодлого оруулж байгаа хүндэт нөхдөө бодлогуудаа
spoiler-т

энэнд хийж байгаач

:wd:

_________________
./node signature.js


Top
   
 Post subject: Re: C++
PostPosted: Feb.04.12 3:28 pm 
Offline
Асуулт Самбарын Хvндэт Харуул
User avatar

Joined: Nov.11.09 5:21 pm
Posts: 7234
Location: Мянган бээрийн аялал ганц алхмаас эхэлдэг.
С дээр бичсэн програмынхаа дотор //**// хаалтанд тайлбараа бичдэг дээ. Тэр тайлбарыг кириллээр яаж бичих вэ? Би Dev C++ хэрэглэдэг. Кириллээр бичингүүт арзайгаад байх юм.

_________________
Нэг л өдрийн наран...


Top
   
 Post subject: Re: C++
PostPosted: Feb.05.12 3:24 am 
Offline
Асуулт Самбарын Хvндэт Харуул

Joined: Jul.31.03 2:44 pm
Posts: 6275
Location: in ma imagination
Тийм боломж байхгүй.
C++ ASCII(unicode) дэмждэггүй, зөвхөн инглийш


Top
   
 Post subject: Re: C++
PostPosted: Mar.15.12 11:51 am 
Offline
Алтан Гургалдай Гишvvн
Алтан Гургалдай Гишvvн
User avatar

Joined: Feb.25.11 3:56 pm
Posts: 415
Location: on a melancholy hill...
Hey энэ жишээ кодыг яаж ажиллуулах талаар зөвлөгөө өгөөч?
client
Code:
/*****************************************************************************/
/*** test-client.c                                                    ***/
/***                                                                       ***/
/*****************************************************************************/

/**************************************************************************
*   This is a port-read client.  It will accept any IP address and port
*   number on the commandline, connect to the server, send the message
*   (if any defined), read the reply, and close.
**************************************************************************/
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <resolv.h>
#include <errno.h>
#include <curses.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <unistd.h>
#include <stdlib.h>

#define MAXBUF   1024

int main(int Count, char *Strings[])
{   int sockfd, bytes_read, x;
   struct sockaddr_in serv;
   char buffer[MAXBUF];
        char *Addr="132.252.150.149";

   /*---Create socket for streaming---*/
   if ( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0 )
   {
      perror("Socket");
      exit(errno);
   }

        puts("Ok1");
   /*---Initialize server address/port struct---*/
   bzero(&serv, sizeof(serv));
   serv.sin_family = AF_INET;
        inet_aton(Addr, (struct in_addr*)&serv.sin_addr.s_addr);
//   if ( inet_aton(Strings[1], &dest.sin_addr.s_addr) == 0 )
//   {
//      perror(Strings[1]);
//      exit(errno);
//   }
   serv.sin_port = htons(atoi(Strings[1]));

        puts("Ok2");
   /*---Connect to server---*/
   if ( connect(sockfd, (struct sockaddr *)&serv, sizeof(serv)) != 0 )
   {
      perror("Connect");
      exit(errno);
   }
   
   sprintf(buffer, Strings[2]);
   send(sockfd, buffer, strlen(buffer), 0);
   recv(sockfd, buffer, MAXBUF, 0);
   printf("\nReceived=%s\n");

/*        puts("ok3");
        x=10;

//   if ( Count == 4 )
        do
   {
      sprintf(buffer, "%s\n", Strings[2]);
      send(sockfd, buffer, strlen(buffer), 0);
//   }

        puts("Ok4");

//   do
//   {
      bzero(buffer, MAXBUF);
      bytes_read = recv(sockfd, buffer, MAXBUF, 0);
      if ( bytes_read > 0 )
         printf("%s", buffer);
                x--;
   }
   while ( x > 0 );
//        puts("CHAT");
//        x=10;
//        do
//        {
//          bzero(buffer, MAXBUF);
//       if ( kbhit() ) buffer[0]=getche();
//     send(sockfd, buffer, strlen(buffer), 0);
//          bzero(buffer, MAXBUF);
//      bytes_read = recv(sockfd, buffer, MAXBUF, 0);
//      if ( bytes_read > 0 )
//         printf("%c", buffer[0]);
//     if ( buffer[0]=='q' ) x=0;
//        }
//       while ( x==0 );
//        puts("FINISH");
//*/
//       /*---Clean up---*/
   close(sockfd);
   return 0;
}


Server
Code:
/*****************************************************************************/
/*** test-port-server.c                                                    ***/
/***                                                                       ***/
/*****************************************************************************/

#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/socket.h>
#include <resolv.h>
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#define MAXBUF   1024

int main(int Count, char *Strings[])
{   int sockfd, newsockfd, cli_len;
    struct sockaddr_in cli_addr;
   struct sockaddr_in sa_serv;
   char* Serv_Addr="132.252.150.149";
   char buffer[MAXBUF];


   /*---Create socket for streaming---*/
   if ( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0 )
   {
      perror("Socket");
      exit(errno);
   }
        puts("Ok1");

        /*---Initialize server address/port struct---*/
   memset (&sa_serv, '\0', sizeof(sa_serv));
   bzero(&sa_serv, sizeof(sa_serv));
   sa_serv.sin_family = AF_INET;
   inet_aton(Serv_Addr, (struct in_addr*)&sa_serv.sin_addr.s_addr);
        sa_serv.sin_port = htons(atoi(Strings[1]));
        puts("Ok2");

   /*---Connect to server---*/
   if ( bind(sockfd, (struct sockaddr *)&sa_serv, sizeof(sa_serv)) != 0 )
   {
      perror("Connect");
      exit(errno);
   }

        puts("Ok3");
        if ( listen(sockfd, 5) !=0 )
        {
      perror("Connect");
      exit(errno);
   }

        puts("Ok4");
        cli_len = sizeof (cli_addr);
        newsockfd = accept (sockfd, (struct sockaddr *)&cli_addr, &cli_len);
        if ( newsockfd < 0 )
        {
      perror("Connect");
      exit(errno);
   }
        a10:
   recv ( newsockfd, buffer, MAXBUF,0 );
   printf("\nReceived=%s\n", buffer);
   sprintf(buffer, Strings[2]);
        send ( newsockfd, buffer, strlen(buffer), 0) ;
        goto a10;
   close(newsockfd);
        return 0;
}

_________________
I'll find u..


Top
   
 Post subject: Re: C++
PostPosted: Mar.15.12 1:37 pm 
Offline
Өсөх Ирээдvйтэй Гишvvн
Өсөх Ирээдvйтэй Гишvvн
User avatar

Joined: Mar.15.12 12:46 pm
Posts: 7
Yaj hurdan C# surahuu help me


Top
   
 Post subject: Re: C++
PostPosted: Mar.21.12 10:43 pm 
Offline
Алтан Гургалдай Гишvvн
Алтан Гургалдай Гишvvн
User avatar

Joined: Feb.25.11 3:56 pm
Posts: 415
Location: on a melancholy hill...
#include <stdio.h>
#include <dos.h>
#include <ctype.h>
#include <conio.h>
#include <stdlib.h>

void main()
{
struct diskfree_t free;
char drive;
unsigned int drive_number;
long int freespace,totspace;
float perspace;

printf("\nPlease Enter Drive Letter : ");
scanf("%c",&drive);
switch (tolower(drive))
{
case 'a' : drive_number=1;
goto end;
case 'b' : drive_number=2;
goto end;
case 'c' : drive_number=3;
goto end;
case 'd' : drive_number=4;
goto end;
case 'e' : drive_number=5;
goto end;
case 'f' : drive_number=6;
goto end;
case 'g' : drive_number=7;
goto end;
case 'h' : drive_number=8;
goto end;
default : drive_number=0;
}
end:

if((_dos_getdiskfree(drive_number,&free))!=0)
{
clrscr();
printf("\n***SORRY! Error in reading the mentioned Device***\n");
exit(1);
}

freespace = (long)free.avail_clusters
* (long)free.sectors_per_cluster
* (long)free.bytes_per_sector;
totspace = (long)free.total_clusters
* (long)free.sectors_per_cluster

Энэ кодыг яаж ажиллуулах вэ?? Маш их хэрэгтэй байна.. Экспертүүд туслаач :think:

_________________
I'll find u..


Top
   
 Post subject: Re: C++
PostPosted: Mar.26.12 6:47 am 
Offline
Ноёлон Ноёрхогч Гишvvн
Ноёлон Ноёрхогч Гишvvн
User avatar

Joined: Oct.25.06 2:00 am
Posts: 1079
Location: cyber world
Икс wrote:
Hey энэ жишээ кодыг яаж ажиллуулах талаар зөвлөгөө өгөөч?
client
Code:
/*****************************************************************************/
/*** test-client.c                                                    ***/
/***                                                                       ***/
/*****************************************************************************/

/**************************************************************************
*   This is a port-read client.  It will accept any IP address and port
*   number on the commandline, connect to the server, send the message
*   (if any defined), read the reply, and close.
**************************************************************************/
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <resolv.h>
#include <errno.h>
#include <curses.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <unistd.h>
#include <stdlib.h>

#define MAXBUF   1024

int main(int Count, char *Strings[])
{   int sockfd, bytes_read, x;
   struct sockaddr_in serv;
   char buffer[MAXBUF];
        char *Addr="132.252.150.149";

   /*---Create socket for streaming---*/
   if ( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0 )
   {
      perror("Socket");
      exit(errno);
   }

        puts("Ok1");
   /*---Initialize server address/port struct---*/
   bzero(&serv, sizeof(serv));
   serv.sin_family = AF_INET;
        inet_aton(Addr, (struct in_addr*)&serv.sin_addr.s_addr);
//   if ( inet_aton(Strings[1], &dest.sin_addr.s_addr) == 0 )
//   {
//      perror(Strings[1]);
//      exit(errno);
//   }
   serv.sin_port = htons(atoi(Strings[1]));

        puts("Ok2");
   /*---Connect to server---*/
   if ( connect(sockfd, (struct sockaddr *)&serv, sizeof(serv)) != 0 )
   {
      perror("Connect");
      exit(errno);
   }
   
   sprintf(buffer, Strings[2]);
   send(sockfd, buffer, strlen(buffer), 0);
   recv(sockfd, buffer, MAXBUF, 0);
   printf("\nReceived=%s\n");

/*        puts("ok3");
        x=10;

//   if ( Count == 4 )
        do
   {
      sprintf(buffer, "%s\n", Strings[2]);
      send(sockfd, buffer, strlen(buffer), 0);
//   }

        puts("Ok4");

//   do
//   {
      bzero(buffer, MAXBUF);
      bytes_read = recv(sockfd, buffer, MAXBUF, 0);
      if ( bytes_read > 0 )
         printf("%s", buffer);
                x--;
   }
   while ( x > 0 );
//        puts("CHAT");
//        x=10;
//        do
//        {
//          bzero(buffer, MAXBUF);
//       if ( kbhit() ) buffer[0]=getche();
//     send(sockfd, buffer, strlen(buffer), 0);
//          bzero(buffer, MAXBUF);
//      bytes_read = recv(sockfd, buffer, MAXBUF, 0);
//      if ( bytes_read > 0 )
//         printf("%c", buffer[0]);
//     if ( buffer[0]=='q' ) x=0;
//        }
//       while ( x==0 );
//        puts("FINISH");
//*/
//       /*---Clean up---*/
   close(sockfd);
   return 0;
}


Server
Code:
/*****************************************************************************/
/*** test-port-server.c                                                    ***/
/***                                                                       ***/
/*****************************************************************************/

#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/socket.h>
#include <resolv.h>
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#define MAXBUF   1024

int main(int Count, char *Strings[])
{   int sockfd, newsockfd, cli_len;
    struct sockaddr_in cli_addr;
   struct sockaddr_in sa_serv;
   char* Serv_Addr="132.252.150.149";
   char buffer[MAXBUF];


   /*---Create socket for streaming---*/
   if ( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0 )
   {
      perror("Socket");
      exit(errno);
   }
        puts("Ok1");

        /*---Initialize server address/port struct---*/
   memset (&sa_serv, '\0', sizeof(sa_serv));
   bzero(&sa_serv, sizeof(sa_serv));
   sa_serv.sin_family = AF_INET;
   inet_aton(Serv_Addr, (struct in_addr*)&sa_serv.sin_addr.s_addr);
        sa_serv.sin_port = htons(atoi(Strings[1]));
        puts("Ok2");

   /*---Connect to server---*/
   if ( bind(sockfd, (struct sockaddr *)&sa_serv, sizeof(sa_serv)) != 0 )
   {
      perror("Connect");
      exit(errno);
   }

        puts("Ok3");
        if ( listen(sockfd, 5) !=0 )
        {
      perror("Connect");
      exit(errno);
   }

        puts("Ok4");
        cli_len = sizeof (cli_addr);
        newsockfd = accept (sockfd, (struct sockaddr *)&cli_addr, &cli_len);
        if ( newsockfd < 0 )
        {
      perror("Connect");
      exit(errno);
   }
        a10:
   recv ( newsockfd, buffer, MAXBUF,0 );
   printf("\nReceived=%s\n", buffer);
   sprintf(buffer, Strings[2]);
        send ( newsockfd, buffer, strlen(buffer), 0) ;
        goto a10;
   close(newsockfd);
        return 0;
}


Сайн уу
Энэ коднуудын ашигласан толгой файлуудаас үзвэл юникс төрлийн үйлдлийн системүүд дээр хөрвүүлэгдэхээр байна. windows дээр cygwin ашиглаад хөрвүүлж болох байх.
Ямар ч байсан миний kubuntu дээр энэ кодууд хэвийн хөрвүүлэгдэж байна.
эхний коодыг хөрвүүлэхдээ
$gcc -o client test-client.c
дараагийнхийг хөрвүүлэхдээ
$gcc -o server test-port-server.c
ингээд server client гэсэн хоёр бинари програм хөрвүүлэгдээд үүсэх болно. ажиллуулахдаа
$./server 45646
$./client 45646
гэх мэтээр дуудаж ажиллуулна.

_________________
whatever!


Top
   
 Post subject: Re: C++
PostPosted: Mar.29.12 3:51 pm 
Offline
Ахмад Гишvvн
Ахмад Гишvvн
User avatar

Joined: Feb.04.09 12:07 pm
Posts: 570
Location: Хаа сайгүй чамтай хамт
Манайхан жагсаалт ашиглан номын сангийн каталоги гэсэн сэдвээр програм бичиж байсна хүн байна уу?
Оролт гаралттай. Програм ажиллаж эхдэхдээ файлаас номын жагсаалтаа уншина. Хийх үйлдлүүд: Засна нэмнэ хасна. Энийг үнэ хөлсийг нь тохиороод хйилгэе тэх үү? Тус болооч

_________________
www.AUTOFORUM.mn


Top
   
 Post subject: Re: C++
PostPosted: Mar.31.12 5:27 pm 
Offline
Асуулт Самбарын Хvндэт Харуул

Joined: Jul.31.03 2:44 pm
Posts: 6275
Location: in ma imagination
Интэрфэйсийнх нь талаар илүү дэлгэрэнгүй хэлж өгнө үү?


Top
   
 Post subject: Re: C++
PostPosted: Mar.31.12 6:52 pm 
Offline
Asuult Precious Member
User avatar

Joined: Feb.07.09 9:44 pm
Posts: 4767
Location: Ulaanbaatar Mongolia
Reega wrote:
Yaj hurdan C# surahuu help me

энд тэнд тусал нтр гээд гүйгэд яваад байвал хэн нэг нь идэвхтэй суугаад чамд зааж өгөхгүй өөрөө хичээгээд сайн судал за С хэлийн хичээл хаа очиж монгол хэл дээрхи ном товхимол зөндөө байдаг

_________________
./node signature.js


Top
   
 Post subject: Re: C++
PostPosted: Apr.01.12 3:22 pm 
Offline
Ахмад Гишvvн
Ахмад Гишvvн
User avatar

Joined: Feb.04.09 12:07 pm
Posts: 570
Location: Хаа сайгүй чамтай хамт
Ямар нэгэн интерфэйс хэрэггүй. Дан код гэх юм уу даа. Боломжтой бол ПМ бичээрэй

_________________
www.AUTOFORUM.mn


Top
   
 Post subject: Re: C++
PostPosted: May.01.12 6:04 pm 
Offline
Өвөг Дээдсийн Сахиус Гишvvн
Өвөг Дээдсийн Сахиус Гишvvн
User avatar

Joined: Jun.07.06 1:42 pm
Posts: 749
Location: In the world
1. Sanamsargui 2 hemjigdehuun uusgeed graphig talbariig 4 huvaaj
baigaad gitogramm shugaman zuraglaliig hiih.
2. Uurusduu usuud buuraad togtvorjood buuraad gesen daraalaltai
ugugdul uusgeed (50) modern regressiin tegshitgeleer zagvarchil
talbaraa 4 huvaana.

Залуусаа энэний учирийг олоод өгөөч...
Би өөрөө нухсан чинь бардаггүй ээ... Хүн бодоод өгөөч гэсэн юм PLZ ALL...

_________________
Надад хөгжилдөх чадал алга...


Top
   
 Post subject: Re: C++
PostPosted: Jun.22.12 10:30 am 
Offline
Төгөлдөр гишvvн
Төгөлдөр гишvvн
User avatar

Joined: May.11.12 12:40 pm
Posts: 80
Dunguj bie daan suraltsaj bgaa oyutan baina aa C++-iin Class gedgiig amarhanaar tailbarlaval yu yum be ?

_________________
King of the rap


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 876 posts ]  Go to page Previous 130 31 32 33 34 Next

All times are UTC+09:00


Who is online

Users browsing this forum: No registered users and 2 guests


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 post attachments in this forum

Search for:
Jump to:  

Copyright Asuult.NET © 2000-2015.
Administrative Contact: Khundaga Khurelbaatar [hundaga@hotmail.com]
Tel: 1-888-303-4927, Fax: 1-888-406-2264.
Powered by phpBB © 2000-2015 phpBB Group. Powered by phpBB® Forum Software © phpBB Limited