sp y

All generations.

generate functionSun, 16 Apr 2023

Realize the function of students filling out their applications on qt

void Application::apply() { if(ui->comboBox->currentText() == "") QMessageBox::warning(this, "Waring", "Please choose your major", QMessageBox::Yes, QMessageBox::Yes); else { QStringList info; info << ui->lineEdit->text() << ui->lineEdit_2->text() << ui->lineEdit_3->text() << ui->comboBox->currentText() << ui->lineEdit_4->text(); emit sendData(info); this->close(); } }

C++
View
generate functionMon, 17 Apr 2023

运用Winsock API编程实现基于UDP协议的点对点双向通信。分别编写两个网络通信程序,以实现点对点通信。 程序1的功能为:发送信息到端口号为6000的远程机上,并可以从端口号6000的远程机接受数据。 程序2的功能为:发送信息到端口号为8000的远程机上,并可以从端口号8000的远程机接受数据。

#include<stdio.h> #include<winsock2.h> #pragma comment(lib, "ws2_32.lib") void main() { WSADATA wsaData; SOCKET RecvSocket; SOCKET SendSocket; SOCKADDR_IN RecvAddr; SOCKADDR_IN SendAddr; SOCKADDR_IN SenderAddr; int Port = 6000; int SenderPort = 8000; char SendBuf[1024]; int BufLen = 1024; int SenderLen = sizeof(SenderAddr); int BytesSent; int RecvAddrLen = sizeof(RecvAddr); int BytesRecv; char RecvBuf[1024]; int iResult; int i; if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) { printf("WSAStartup failed with error %

C++
View
generate functionMon, 17 Apr 2023

运用Winsock API编程实现基于UDP协议的点对点双向通信。分别编写两个网络通信程序,以实现点对点通信。 程序1的功能为:发送信息到端口号为6000的远程机上,并可以从端口号6000的远程机接受数据。 程序2的功能为:发送信息到端口号为8000的远程机上,并可以从端口号8000的远程机接受数据。

#include<Winsock2.h> #include<stdio.h> #include<conio.h> #include<string.h> #pragma comment(lib,"ws2_32.lib") #define MAX_LENGTH 1024 void main() { WORD wVersionRequested; WSADATA wsaData; int err; char sendBuf[MAX_LENGTH]; char recvBuf[MAX_LENGTH]; memset(sendBuf,0,MAX_LENGTH); memset(recvBuf,0,MAX_LENGTH); wVersionRequested=MAKEWORD(2,2); err=WSAStartup(wVersionRequested,&wsaData); if(err!=0) { printf("\n[Error]WSAStartup() returned with error code: %d\n",err); _getch(); return; } //

C++
View
generate functionMon, 17 Apr 2023

运用Winsock API编程实现基于UDP协议的点对点双向通信。分别编写两个网络通信程序,以实现点对点通信。 程序1的功能为:发送信息到端口号为6000的远程机上,并可以从端口号6000的远程机接受数据。 程序2的功能为:发送信息到端口号为8000的远程机上,并可以从端口号8000的远程机接受数据。

#include <winsock.h>//应用程序需要这个头文件才能调用Windows Socket API函数 #include <time.h> #include <stdio.h> #include <conio.h> #pragma comment(lib,"wsock32.lib")//这句话用于链接编译器和库文件wsock32.lib,使程序运行时可以使用Windows Socket API函数。 //如果不使用这句话,编译器将报告找不到wsock32.lib库文件。 //如果使用了这句话,编译器还是会报

C++
View
generate functionMon, 17 Apr 2023

运用Winsock API编程实现基于UDP协议的点对点双向通信。分别编写两个网络通信程序,以实现点对点通信。 程序1的功能为:发送信息到端口号为6000的远程机上,并可以从端口号6000的远程机接受数据。 程序2的功能为:发送信息到端口号为8000的远程机上,并可以从端口号8000的远程机接受数据。

#include<stdio.h> #include<winsock2.h> #include<string.h> #include <iostream> using namespace std; #pragma comment(lib, "ws2_32.lib") int main(int argc, char* argv[]) { WSADATA wsaData; WSAStartup(MAKEWORD(2, 2), &wsaData); SOCKET sockServer = socket(AF_INET, SOCK_DGRAM, 0); SOCKADDR_IN addrServer; addrServer.sin_addr.S_un.S_addr = htonl(INADDR_ANY); addrServer.sin_family = AF_INET; addrServer.sin_port = htons(6000); bind(sockServer, (SOCKADDR*)&addrServer, sizeof(SOCKADDR)); char recvBuf[100] = { 0 }; char sendBuf[100] = { 0 };

C++
View
generate functionSun, 16 Apr 2023

Realize the function of students filling out their applications on qt

void saveStudentInfo(QString &name, QString &sex, int age, int num, QString &class) { QSqlQuery query; query.exec("create table studentInfo (name varchar(255), sex varchar(255), age int, num int, class varchar(255))"); query.prepare("INSERT INTO studentInfo(name, sex, age, num, class) " "VALUES (:name, :sex, :age, :num, :class)"); query.bindValue(":name", name); query.bindValue(":sex", sex); query.bindValue(":age", age); query.bindValue(":num", num); query.bindValue(":class", class); query.exec(); }

C++
View
generate functionMon, 17 Apr 2023

运用Winsock API编程实现基于UDP协议的点对点双向通信。分别编写两个网络通信程序,以实现点对点通信。 程序1的功能为:发送信息到端口号为6000的远程机上,并可以从端口号6000的远程机接受数据。 程序2的功能为:发送信息到端口号为8000的远程机上,并可以从端口号8000的远程机接受数据。

#include "stdafx.h" #pragma comment(lib, "ws2_32.lib") #include <WinSock2.h> #include <stdio.h> int _tmain(int argc, _TCHAR* argv[]) { printf("client demo\n"); WORD wVersionRequested; WSADATA wsaData; int err; wVersionRequested = MAKEWORD(1, 1); err = WSAStartup(wVersionRequested, &wsaData); if (err != 0) { return -1; } if (LOBYTE(wsaData.wVersion) != 1 || HIBYTE(wsaData.wVersion) != 1) { WSACleanup(); return -1; } SOCKET sockClient = socket(AF_INET, SOCK_DGRAM, 0); SOCKADDR_

C++
View

Want to kickstart your project?Use the new AI Studio to create your code