language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <strings.h> #include <sys/types.h> #include <sys/socket.h> #include <unistd.h> #include <netinet/in.h> #include <arpa/inet.h> #include <sys/stat.h> //for file stats #include <unistd.h> //for checking file access #include <libgen.h> //for getting...
C
#include<stdio.h> int main() { int choice,n,i; float a,b, ans=0; printf("**********Simple calculator**********\n"); printf("Make your choice: \n1. press '1' for addition\n2. press '2' for subtraction\n3. press '3' for multiplication\n4. press '4' for division\n"); scanf("%d",&choice); if (choice==...
C
#ifndef projet1c_h #define projet1c_h // Bibliothèques #define MAX_BLOCK 5 #define INJOUABLE -1 #define LIBRE 0 #define OCCUPE 1 #define LIGNE 0 #define COLONNE 1 #include <stdio.h> #include <stdlib.h> #include <time.h> // Fonctions de bases int** create_2D_Array(int nb_lig, int nb_col); void fill_2D_plateau_C...
C
#include <stdio.h> #include <omp.h> int main() { int read,writ,readcount=0,value=0; printf("Enter the number of readers\n"); scanf("%d",&read); printf("Enter the number of writers\n"); scanf("%d",&writ); omp_set_num_threads(read+writ); omp_lock_t wlock,rlock; omp_init_lock(&wlock); omp_init_lock(&rlo...
C
#include <string.h> #include <stdlib.h> #include <stdint.h> #include <stdio.h> #include "../include/text_buffer.h" #include "../include/utf8.h" #include "../include/utf8_buffer.h" utf8_buffer * utf8_buffer_new(int capacity) { return text_buffer_new(capacity); } void utf8_buffer_destroy(utf8_buffer * buf) { t...
C
#include <pthread.h> #include <unistd.h> int numero =4; pthread_mutex_t mutex; typedef struct params { int n; }param; void * duplicaN(void *p) { pthread_mutex_lock(&mutex); int i; int temp = numero; for(i =0; i < ((param*)p)->n; i++) { temp *= 2; printf("Duplica %d \n", temp); sleep(5); } ...
C
#include <stdio.h> #include <string.h> typedef unsigned char *byte_pointer; void show_bytes(byte_pointer start, size_t len) { int i; for (i = 0; i < len; i++) printf(" %.2x", start[i]); printf("\n"); } int main(int argc, char *argv[]) { const char *m = "mnopqr"; show_bytes((byte_pointer) ...
C
#include <stdio.h> int main(void) { int m,i; int a[5]={2,1,2,1,5}; int flag; for(i=0;i<5;i=i+m) { m=a[i]; if(i==4) { flag=0; } } if(flag==0) { printf("true"); } else { printf("false"); } return 0; }
C
/************************************************************************* > File Name: ER-45.c > Author: liqiang > Mail: 1398690148@qq.com > Created Time: 2019年07月29日 星期一 19时02分45秒 ************************************************************************/ #include <stdio.h> #include <inttypes.h> int...
C
#include <stdlib.h> #ifndef HASH_TABLE_H #define HASH_TABLE_H #endif #define NO_KEY -1 #define NOT_FOUND -1 /* Intially a hash table is created with a given size. We don't change the size since. In case of collision we simply chain it at the position determined by the hash function. +---------+ | ...
C
#include "polygon.h" Polygon polygon_create(int num_points, Point points[]) { Polygon poly = {num_points, NULL}; if (num_points >= 3) { poly.points = calloc(num_points, sizeof(Point)); int i; for (i = 0 ; i < num_points ; ++i) { poly.points[i] = points[i]; } } return poly; } double poly...
C
#ifndef _CLIENT #define _CLIENT #include "functions.h" int main(int argc, char **argv){ launch_serv_if_abs(); int srv_fd = open(MAIN_PIPE, O_WRONLY); exit_if(srv_fd == -1, "Main pipe open"); // Open fifo file in read only #ifdef DEBUG printf("DEBUG : fifo file %s is open for write\n", M...
C
/* * Command line interface, used under the DADT license */ #ifndef CLI_H #define CLI_H /* * Configuration */ #define configCOMMAND_INT_MAX_OUTPUT_SIZE 255 /* * Port */ #define portBASE_TYPE unsigned #define pdTRUE 1 #define pdFALSE 0 #define pdPASS 1 #define pdFAIL 0 #define pvPortMalloc malloc #define taskEN...
C
#include <stdlib.h> #include "holberton.h" /** * _calloc - character allocate * Description: Allocates memory for an array and sets each element to zero * @nmemb: Number of elements in the array * @size: Size of each element * Return: Pointer to allocated memory, or NULL if unsuccessful. */ void *_calloc(unsigne...
C
#include<stdio.h> int main(){ int num,i; FILE *fp; fp = fopen("Tables.txt","w"); printf("Enter the number you want table of:"); scanf("%d",&num); fprintf(fp,"Table of %d\n",num); for(i=0;i<10;i++){ fprintf(fp,"%d * %d = %d\n",num,i+1,num * (i+1)); } //fclose(fp); return 0; }
C
// Sum of numbers #include <stdio.h> #include <pthread.h> #include <stdlib.h> struct arg_struct { int a[100]; int n; }; void* child_thread(void *param) { struct arg_struct *args = (struct arg_struct *) param; int sum = 0; for(int i = 0; i < args->n; i++) { if(args->a[i] >= 0) sum += args->a[i]; } return ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* actions3.c :+: :+: :+: ...
C
#include<stdio.h> #include<string.h> int main() { char str1[100],str2[100]; int count=0; printf("enter main string:"); scanf("%s",&str1[0]); printf("enter substring:"); scanf("%s",&str2[0]); int len1 = strlen(str1); printf("len1=%d\t",len1); int len2 = strlen(str2); printf("len2:%d\n",len2); for(int i=0;i<=l...
C
/* Class: State Member Function: testCheckWhite Checks if the king of current player is in check or not. Return true or false. */ bool State::testCheckWhite(){ // Get the current position of the King pair<int, char> pos = White.getPosFromPiece("K"); int r = pos.first; char c = pos.second; int i = r + 1...
C
/****************************************************************************** QUEUE ADT Type definitions and function prototypes for the queue ADT Written by: Iain S. Davis Date: 11 Jun 2013 *******************************************************************************/ #include <stdio.h> #include <stdlib.h>...
C
// Author: Anthony Huynh // Class: CS 344 // Project: Program 2 - adventure // Date Due: 11/1/2019 //outline from https://oregonstate.instructure.com/courses/1738958/pages/2-dot-2-program-outlining-in-program-2 was used #include <stdio.h> #include <string.h> #include <sys/types.h> #include <unistd.h> #include <stdli...
C
#include <stdio.h> int fib (int n) { if (n < 2 ) return n; return fib(n-1) + fib(n-2); //O(k^n) } int main(void) { int n = fib(42); printf("%d\n",n); return 0; }
C
#include <stdio.h> #include <stdlib.h> int employee; struct Employee_details { char* name; char* company; }*emp; void Display(char *,char *); int main() { int n, m; char choice; printf("*****Welcome to ABC pvt. limited *****\n"); printf("*****Here you can enter your employee id details***...
C
#include <stdio.h> #include <stdlib.h> #include "hashtable.h" /* * HashTable è una struttura dati che mappa una chiave in un valore * il caso peggiore di ricerca è di O(1+a) se m < n dove a = n/m. * m = numero di slot della tabella, cioè quante chiavi differenti possiamo salvare nella * tabella...
C
#include "barrier.h" #include <pthread.h> #include <sys/mman.h> /* * 1) Wpuść N - 1 * 2) Wpuść N, zamknij A, otwórz B * 3) Wywal N - 1 * 4) Otwórz A, zamknij B * * \ / * \_____________/ * A| N miejsc |B * |_____________| * / \ * / \ */ /* * Zaim...
C
#include <stdio.h> #include <stdlib.h> #define INSERT 1 #define DELETE 2 #define PRINT 3 #define EXIT 0 #define TRUE 1 #define FALSE 0 struct node{ struct node *_next; int value; }; typedef struct node *_PtrNode; typedef struct node NODE; void menu(void); void insert(_PtrNode*,int); void print(_PtrNode*); i...
C
#include <stdio.h> /* printf */ #include <stdlib.h> #include <time.h> /* We want a BOARD_SIZExBOARD_SIZE board game by default */ #define BOARD_SIZE 5 char board[BOARD_SIZE * BOARD_SIZE] = { 0 }; // Filled with zeros char get_cell(int x, int y) { return board[y * BOARD_SIZE + x]; } void set_cell(int x, int ...
C
/* * @Copyright(C): 信念D力量 (freerealmshn@163.com) * All Rights Reserved. * ********************************************** * @FilePath: /CExample/lists-demo/loop-list.c * @Author: 信念D力量 * @Github: https://www.github.com/fy2008 * @Date: 2020-09-05 21:49:48 * @LastEditTime: 2020-09-09 22:25:16 * @Description: 循环单链...
C
/* Transliterates every byte from STDIN if it matches * a character in the first string to the respective * character in the second string */ #include <stdio.h> #include <stdlib.h> #include <stdbool.h> /* Checks for errors in processing STDIN or printing to STDOUT */ void checkInput() { if (ferror(stdin) != 0) {...
C
#ifndef __SKIP__ #define __SKIP__ //FOR VACCINATED SKIPLIST struct VacSkipRecord{ //the info we want to keep at the list char* name; char* date; }; struct VacPtrNodes{ //nodes to represent the element in each level struct VacSkipRecord* elem; //pointer to the node with the element it represents...
C
#include <stdio.h> #include "list.h" #include "listmenu.h" void printMenu(MenuItems *menuitems, struct List* list){ printf("MAIN MENU\tC:%d\tH:%p\tT:%p\n", Count(list), list->head, list->tail); int i = 0; for(i; i < menuitems->count; i++){ printf("[%d]\t%s\n", i, menuitems->items[i].name); } ...
C
#include <stdio.h> #include "irgenerator.h" static void printFunction (const Function*); static void printOp (const IROp*); static void printSymbol (const Symbol*); static void printImport (const Import*); static void printConstants (const Constants*); void irgen_print(IRGenerator* p) { printf(...
C
#include"/Users/amuthanmannan/Documents/collection/Collection-API-in-C copy/collection.h" LinkedList* linkedlist(){ LinkedList* list; list=(LinkedList*)malloc(sizeof(LinkedList)); list->head=NULL; list->tail=NULL; list->size=0; return list; } Node* init_node(void* data){ Node* n; n=(Node*)malloc(size...
C
#include <stdio.h> #include <string.h> int main() { int c; char s[100],*p; scanf("%s",s); c = strlen(s); p = &s[c-1]; while(p!=s) { printf("%c", *p--); } printf("%c\n", *p); return 0; }
C
/** * A small module for testing powerfulness of numbers. * * References on powerful numbers: * http://en.wikipedia.org/wiki/Powerful_number * http://oeis.org/A001694 * http://mathworld.wolfram.com/PowerfulNumber.html * * Author: Vasilis Poulimenos * Date: 3/1/2015 * Version: 1.0.0 */ #ifndef IS...
C
#include<stdio.h> void main() { int n,i,sum=0; printf("Enter any digit: "); scanf("%d",&n); while(n>0) { i=n%10;//Remainder if(i%2==0) { sum=sum+i; } n=n/10; } printf("Sum=%d\n",sum); }
C
#include "uart.h" #include "allocater.h" #include "tools.h" #include "exception.h" static int time = 0; char *entry_error_messages[] = { "SYNC_INVALID_EL1t", "IRQ_INVALID_EL1t", "FIQ_INVALID_EL1t", "ERROR_INVALID_EL1T", "SYNC_INVALID_EL1h", "IRQ_INVALID_EL1h", "FIQ_INVALID_EL1h", "ERROR_INVALID_EL...
C
//factorial using recursion #include<stdio.h> int fact(int x) { int f; if(x==0) { return(1); } else{ f=x*fact(x-1); return(f); } } int main() { int no,ans; scanf("%d",&no); ans=fact(no); printf("the answer is %d",ans); }
C
#include <stdio.h> #include <stdlib.h> int main() { int d, m, nm, dem; scanf("%d %d %d", &d, &m, &nm); if((d<=7) && (d>=2) && (m>=1) && (m<=12) && (nm>=28) && (nm <=31)) { printf("Thang %d\n", m); printf("Thu Hai Thu Ba Thu Tu Thu Nam Thu Sau Thu Bay Chu Nhat \n"); dem=1; for(int i=1; i<=7; i...
C
#include<iostream> int main() { using namespace std; cout.setf(ios_base::fixed, ios_base::floatfield); cout << "Interger division: 9/5 = " << 9/5 << endl << "Floating-point division : 9.0/5.0 = " << 9.0/5.0 <<endl << "Mixed division: 9.0/5 = " << 9.0/5 << endl << "double...
C
#include <stdio.h> int newton(int n,int k) { if(k==0 || k==n) { return 1; } if(n>k && k>0) { return newton(n-1,k-1)+newton(n-1,k); } } int main() { int x,y; scanf("%d %d",&x,&y); printf("%d\n",newton(x,y)); }
C
#include <stdio.h> #include <stdlib.h> int main() { int vertex=0; int node=0; int orientation=0; int weightiness=0; int c; char input[20]; printf("Type name of input file:\n"); scanf("%s", input); FILE *MatrixFile=fopen(input, "r"); if (MatrixFile == NULL) { ...
C
/********************************* * Class: MAGSHIMIM C2 * * Week 3 * * HW solution * **********************************/ #include <stdio.h> #include <string.h> void printArray(char* p, int len) { char* ogp = p; // the original p for (p; p < ogp + len; p++) { printf("%c", *p); } prin...
C
//Meeting of old friends #include<stdio.h> int main() { long long int l1,l2,r1,r2,i,j,cnt; while(scanf("%lld %lld %lld %lld %lld",&l1,&r1,&l2,&r2,&k)==5) { cnt=0; for(i=l1;i<=r1;i++) { for(j=l2;j<=r2;j++) if(i==j && i!=k) cnt++; if(i==j &&...
C
#include "task.h" #include <stdio.h> int main(){ int a; int b; printf("Write two numbers:\n"); scanf("%u%u", &a, &b); swap(&a,&b); printf("The answer is %d", gcdCyc(a, b)); }
C
#include<stdio.h> void PrencheVect(); void Menu(); int vect[5]; int tam = sizeof(vect) / sizeof(int); int main() { Menu(); //CHAMA O MENU GERAL return 0; } void PrencheVect() { int elemento=0; for (int i = 0; i < tam; i++) { printf("== DIGITE O %d ELEMENTO DO VETOR :",(i+1)); scanf_s("%d", &elemento); } }...
C
/* ** EPITECH PROJECT, 2020 ** tools.c ** File description: ** all the usefull functions */ #include "../include/rpg.h" void my_putchar(char c) { write(1, &c, 1); } void my_putstr(char *str) { for (; *str != '\0'; str++) my_putchar(*str); } void my_puterr(char d) { write(2, &d, 1); } void my_pu...
C
#include <stdlib.h> #include <stdio.h> #include <math.h> int primeCheck(int num) { for(int i=2;i<num/2;i++) { if(num%i==0) return 0; } return 1; } int rotRight(int num, int size) { int digits[size]; int temp = num; for(int i=size-1;i>=0;i--) { digits[i]=...
C
//#HW09 //ALP EMİR BİLEK //161044049 #include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> int main() { //ARRAY'A RASTGELE SAYILAR ATIYORUZ. srand(time(NULL)); //20'LİK ÜÇ ARRAY TANIMLIYORUZ. int array2[20]; int array3[20]; int array1[20]; // DEĞİŞKENLERİMİZİ TANIMLIYORU...
C
//Isso é um comentário de uma linha. ///Isso é um comentário de documentação de varias linhas, vou usar esse pois é mais legivel que o cinza. /* Isso é um comentário de várias linhas. */ /** Isso é um comentário de documentação de várias linhas. */ #include <stdio.h> ///Essa é a bliblioteca que contém as dec...
C
/** * @fichier main.c * @titre Convolution 2D * @description Convolution 2D avec la programmation concurrente * @auteurs Kevin Estalella & Federico Lerda * @date 21 Octobre 2015 * @version 1.0 */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <pthread.h> #include "time.h" //librarie utilisée pour c...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #define OUTPUT_NAME "output.c" #define LUT_SIZE 0xFF #define AVAILABLE_MEMORY "1024" #if defined(__clang__) #define COMPILER "clang" #else #define COMPILER "gcc" #endif int main(int argc, char **argv) { if (argc < 2) { printf("Not enough arguments\...
C
#pragma once struct VoxelInfo { float4 min; // float4 float4 size; // float4 uint4 voxels_per_tile; // uint4 uint4 voxel_tiles_count; // uint4 float4 GetMin() { return min; } float4 GetSize() { return size; } uint4 GetVoxels_per_tile() { return voxels_per_tile; } uint4 GetVoxel_tiles_count() { return voxel_tile...
C
/* ** minishell.c for minishell in /home/macmil_r/rendu/PSU_2013_minishell1 ** ** Made by a ** Login <macmil_r@epitech.net> ** ** Started on Fri Dec 13 16:45:11 2013 a ** Last update Sat Mar 8 21:47:15 2014 a */ #include <unistd.h> #include <stdlib.h> #include "minishell.h" char **path(char **tab, char **en...
C
// 2.3#include <stdio.h> // int main() // { // int i ; // for ( i = 1; i <= 100; i++) // { // if (i%2==0) // { // printf("%d\n ", i); // } // } // return 0; // } // 2.8#include <stdio.h> // int main() // { // float x, y; // scanf("%f%f...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strchr.c :+: :+: :+: ...
C
#include<stdio.h> #include<unistd.h> #include<sys/shm.h> #include<string.h> main(int argc, char** argv) { int i,k=1; key_t key= ftok("shmfile",65); int shmid =shmget(key,1024,0666|IPC_CREAT); char *str =(char*) shmat(shmid,(void*)0,0); for(i=0;i<argc;i++) { strcpy(str,argv[i]); } printf("Address is %d",&str); printf("...
C
#include "TDA_lista.h" bool_t TDA_Lista_vacios(lista_t lista) { return lista==NULL; } status_t TDA_Lista_crear(lista_t * plista) { if(plista == NULL) return ST_ERROR_PUNTERO_NULO; *plista = NULL; return ST_OK; } status_t TDA_Lista_crear_nodo(nodo_t ** pnodo, void * dato) { if(pnodo == NULL) return ST_ER...
C
#include <stdio.h> #include <string.h> #include "dataio.h" int modify_credit(name, price) const char* name; int price; { char filename[20]; int i; int credit; FILE* person_data; strcpy(filename, "DATA\\"); i = 5; strncpy(&filename[i], name, 8); if (strlen(name) > 8) { i...
C
// test_search_functions.c // <Teng-Ju Yang tyang28> #include <stdio.h> #include <assert.h> #include "search_functions.h" #include <stdlib.h> #include <string.h> #include <ctype.h> /* * Declarations for tester functions whose definitions appear below. * (You will need to fill in the function definition details, at...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <errno.h> double f(double x); double Lagrange(double (*f)(),double *p, int order, double x); int main() { double p[5] = { 1, 1.1, 1.2, 1.3, 1.4 }; /* Store polynomial factors here:*/ puts("Will approximate f(x) = e^2x -1 with 4th order lagrange...
C
/* ************************************************************************** */ /* LE - / */ /* / */ /* simplesort.c .:: .:/ . .:: ...
C
/* * Author: manuel * E-mail Manuel_Angel99@outlook.com * Created: 2016-08-30 16:44:00 * * File: getchar.c * Description: Implements the C standard getchar function wich returns the first character in the wrote line and prints the input */ #include <stdio.h> int getchar(void) { char buffer[1]; size_t lenght ...
C
#include <stdio.h> int main() { int v = 1 == 1; printf("1: %d\n", v); v = 1 != 1; printf("2: %d\n", v); v = (3*3.2) < (4*2.3); printf("3: %d\n", v); float f1 = 2.781; float f2 = 3.14156; v = (f2 >= f1); printf("4: %d\n", v); double f3 = 3.1415600000000000001; v...
C
#include<stdio.h> int main() { char c[] = "#Amit"; char *p =c; printf("%s %d",p,'aa'); }
C
#include "mylist.h" struct s_node *node_at(struct s_node *head, int n) { assert(n >= 0); assert(head != NULL); if (head != NULL) { struct s_node *temp; if (n <= 0) { return head; } temp = head; while (n > 0) /* loop through list */ { if (temp -> next == NULL) /*if we reach end of list, return l...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> int compareFiles(FILE *fp1, FILE *fp2) { char ch1 = getc(fp1); char ch2 = getc(fp2); int error = 0; while (ch1 != EOF && ch2 != EOF) { if (ch1 != ch2) { error++; } ch1 = getc(fp1); ...
C
#include<stdio.h> #include<conio.h> #include<stdlib.h> void display() { extern int x; //we cannot use the global declared variable unless we use the keyword extern datatype variable printf("%d",x); } int main(){ extern int x; printf("%d\n",x); display(); getch(); return 0; } int x =...
C
#include "apue.h" int main(void) { struct stat statbuf; /* git foo's file info */ if(stat("foo",&statbuf) < 0){ err_sys("stat error for foo"); } /* turn on set-group-ID and turn off group-execute */ if(chmod("foo",statbuf.st_mode & ~S_IXGRP | S_ISGID) < 0){ err_sys("chmod error for foo"); } /* set abso...
C
#include<stdio.h> #include<stdlib.h> /** * @struct QueueNode * @desc Contains item and pointer to next QueueNode. */ struct QueueNode { int item; struct QueueNode* next; }; /** * @struct Queue * @desc Contains pointers to first node and last node, the size of the Queue. */ struct Queue { struct Queu...
C
#include <stdio.h> #include <signal.h> int main(int argc, char **argv) { int sig, i; pid_t pid; pid = atoi(argv[1]); for (i = 2; i < argc; i++) { sig = atoi(argv[i]); kill(pid, sig); } }
C
#include<stdio.h> //function:input a decimal and output its binary form void to_bin(int n){ int r=n%2; if(n>=2) to_bin(n/2); putchar(r?'1':'0'); } int main(){ int n; scanf("%d",&n); to_bin(n); return 0; }
C
#include<stdio.h> #include<stdlib.h> struct node{ struct node *prev; int data; struct node *next; }*head=NULL; int count=0; void count_length() { struct node *temp=head; int c=0; while(temp!=NULL) { c++; temp=temp->next; } count=c; } void Insertion_At_front(int data) { struct node *ne...
C
unsigned udb_int (unsigned n, unsigned * keys) { ght_hash_table_t * ht = ght_create (n); unsigned i; unsigned count; for (i = 0; i < n; i ++) { if (ght_get (ht, sizeof (keys [i]), & keys [i])) ght_remove (ht, sizeof (keys [i]), & keys [i]); else ght_insert (ht, (void *) & keys [i], sizeof (k...
C
/* * Program name --- crosscompo.c */ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <time.h> #include <sys/time.h> #include "crossmatch.h" #define BUFFER 100 #define FUNCTION 1 // 0: L1 distance, 1: euclid distance extern double epsilon; extern struct SeqList *list; e...
C
#include "stdio.h" #include "cmap.h" #define NVAL (1024 * 1024) int main() { CMap *map = cmap_init(); int a[1024 * 1024]; char **s; s = (char**)malloc(sizeof(char*) * NVAL); int i; printf("Populating arrays ...\n"); for (i = 0; i < NVAL; ++i) { a[i] = i; s[i] = (char*)mallo...
C
/* Header files stdio.h - for printf stdlib.h - for exit function */ #include <stdio.h> #include <stdlib.h> /* Help function */ void help_function() { /* Print help details and exit */ printf("Usage: cfs <URL>\n"); printf("<URL>\t\t Support http, https, port, path \n"); printf("If no a...
C
#include "apue.h" int main(int argc, char *argv[]) { int bytes; int a, b; char line[MAXLINE]; while ( (bytes = read(STDIN_FILENO, line, MAXLINE)) > 0) { /* null terminate */ line[bytes] = 0; if (sscanf(line, "%d%d", &a, &b) == 2) { sprintf(line, "%d\n", a + b); bytes = strlen(line); write(STDO...
C
/** ** main.c ** spor command line **/ /* TODO * - an optional outfd for a passthru hash? * - use varargs in macros */ #include <string.h> #include <stdlib.h> #include <unistd.h> #include "spor.h" #include "spor_ltc.h" #include "util.h" #define EXE "spor" #define PWPROMPT "Password: " #define PWCONFIRM "Con...
C
#include "queue.h" #include "robio.h" void Queue_Initialize(Queue * queue) { queue->start = 0; queue->end = 0; queue->current_count = 0; } int Queue_PushEnd(Queue * queue, QUEUE_ITEM_TYPE item) { if ((queue->end + 1) % QUEUE_SIZE == queue->start) { return ERR_QUEUE_FULL; } assert((int)item, "Queue_PushEnd: ...
C
#include <stdio.h> // Call back function void funcA(); void funcB(void(*pFunc())); int main(int argc, char const *argv[]) { printf("Lets start...\n"); void (*pFunc)() = &funcA; // Calling a function with callback funktion as argument funcB(pFunc); return 0; } void funcA(...
C
/* HEADER: CUG205.00; TITLE: WORDS for Microsoft; DATE: 09/24/86; DESCRIPTION: "Places words on individual lines."; KEYWORDS: Software tools, Text filters, words, make words; SYSTEM: MS-DOS; FILENAME: WORDS.C; WARN...
C
#include <string.h> class N { char _str[64]; int _nb; public: N(int nb) { _nb = nb; } void *setAnnotation(char *str) { int len = strlen(str); return (memcpy(this->_str, str, len)) } virtual void operator+(N *n) { ...
C
#include <stdio.h> int main() { int n=50, i, x; int vet[n]; // DETERMINANDO VALORES AO VETOR for(i=0; i<n; i++){ vet[i] = 1; } i=0; // ALTERAR OS VALORES DO VETOR ATE UM VALOR SER 0 do{ scanf("%d", &vet[i]); if(vet[i] != 0){ i++; } }while(vet[i] != 0); i=0; // MOSTRANDO...
C
#include "stdio.h"; signed int factorial (signed int x,) { signed int output = 1; signed int i = 0; while (i < x) { output = output * i; i = i + 1; } return output; } void main () { signed int x = 10; signed int y = 10; signed int z = x + y; if (x + y == z) { z = z + z; } else { z = z - z; } }
C
/*========================================================= 第3-6節 ListConcate() ========================================================= */ #include <stdio.h> #include <stdlib.h> typedef struct tagListNode { int data; struct tagListNode* next; } ListNode; int InsertTail(ListNode*, int)...
C
#include <stdio.h> #include <fcntl.h> int main(void) { int intvar; FILE *fp; char stringvar[80]; float floatvar; ///char ready[80]; fp = fopen("/home/bheckel/junk2.txt", "r"); ///char *mystr = "5 words 6.0"; fscanf(fp, "%d %s %f", &intvar, stringvar, &floatvar); ///sscanf(mystr, "%d %s %f", &intvar...
C
#include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <string.h> int main(int argc, char **argv) { FILE *ifh; size_t rb; char *buf; int ret; const size_t bufsize = 257; if (argc < 2) { fprintf(stderr, "Need command-line arg.\n"...
C
#include <stdio.h> int main() { int p; register int i = 5; // Note: if the register request is not honored the auto sc will be used. printf("i = %d\n", i); printf("%u\n", &p); // printf("%u\n", &i); // Note: you cannot find the address of a register variable return 0; }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* print_memory.c :+: :+: :+: ...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <stdbool.h> void calculate_bribe(int *q, int qcount){ int bribe_cnt = 0, max; bool found_chaotic = false; for (int j = qcount - 1; j >= 0; j--){ // Calculate if chaotic queue found and break if necessary if(q[j] - (j + 1) > 2){ ...
C
#include<stdio.h> int main() { int X,P; //X is price of coffee and P is discount rate int total_amount=0; //entire amount to pay in order to get it as FREE scanf("%d%d",&X,&P); P=100-P; while(X>0) { total_amount= total_amount + X; X = (P*X)/100; } printf...
C
/*īI * MicroSDTFSPIģʽʵַ * http://www.cnblogs.com/einstein-2014731/p/4885382.html * * nios ii֮Micro SDTFspia * https://blog.csdn.net/ming1006/article/details/7283689# */ #include "include.h" #define MICROSD_CS PTB20_OUT //CS #define MICROSD_DI PTB21_OUT //DI #define MICROSD_CL...
C
#include <stdio.h> //int main() { // int a = 10; // int *pi; // int **ppi; // // pi = &a; // ppi = &pi; // // printf("--------------------------------------------------\n"); // printf(" & * **\n"); // printf("--------------------------------------------------\n"); // printf("a%10d%10u\n", a, &a); // p...
C
/* Title : 9_median.c Author : Sandeep Date : 12 June 2019 Description : Reading two different unsorted arrays, finding median for those two arrays and finally finding the average of two medians Input : Two arrays, Number of terms in first and second array output : Sorted arrays, Medians...
C
/** ** Copyright 2017-2018 Lu <miroox@outlook.com> ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by a...
C
#include "hashTable.h" #include "io.h" void initializeHT(int N) { //! initialize hash table with length "INITIAL_HT_SIZE_FACTOR" of N (1/4 of N) size = INITIAL_HT_SIZE_FACTOR * N; hT = (char **) malloc(sizeof(char *) * size); for (int i = 0; i < size; ++i) { hT[i] = NULL; } } float getFill...
C
#include <stdio.h> int main() { long long int i,num,sum=0,sump=0; printf("Enter No "); scanf("%lld",&num); int temp = num; while(num>0) { i = num % 10; sum = sum + i; num /=10; } printf("Sum of All Digit %lld\n",sum); return 0; }
C
/* Pippolo - a nosql distributed database. Copyright (C) 2012 Andrea Nardinocchi (nardinocchi@psychogames.net) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the L...
C
/* ** my_aff_comb2.c for my_aff_comb2 in /home/wuilla_j/rendu/Piscine_C_J03 ** ** Made by Julien Wuillaume ** Login <wuilla_j@epitech.net> ** ** Started on Wed Sep 30 11:33:29 2015 Julien Wuillaume ** Last update Wed Sep 30 20:13:04 2015 Julien Wuillaume */ int my_putchar(char c) { write(1, &c, 1); } int numbe...