Skip to content

Instantly share code, notes, and snippets.

@redatawfik
redatawfik / posix_client.cpp
Created June 12, 2020 04:23
Client implementation for POSIX client-server program
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#define SIZE 2
@redatawfik
redatawfik / posix_server.cpp
Created June 12, 2020 04:21
Server implementation for POSIX client-server program
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define SIZE 2
int main() {
@redatawfik
redatawfik / client.cpp
Last active June 13, 2020 03:01
Client implementation of client-server chat using Winsock
#include <winsock2.h>
#include <iostream>
char szServerIPAddr[20] = "192.168.1.4"; // Put here the IP address of the server
int nServerPort = 5050; // The server port that will be used by // clients to talk with the server
bool InitWinSock2_0();
using namespace std;
@redatawfik
redatawfik / server.cpp
Created June 12, 2020 03:52
Server implementation of client-server chat using Winsock
#include <winsock2.h>
#include <iostream>
struct CLIENT_INFO {
SOCKET hClientSocket;
struct sockaddr_in clientAddr;
};
char szServerIPAddr[] = "192.168.1.4"; // Put here the IP address of the server
int nServerPort = 5050; // The server port that will be used by
package CTCI;
import java.util.Scanner;
public class BitManipulation {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);