G

@genie

24.02.27. struct

C
2 years ago
/* a program of printing patients' info -struct Patient{} -get info of 3 patient from console -print all the elements */ struct Patient{ char name[50]; //DON'T: char *name[50] char idNumb[100]; int age; };

24.02.27 struct&typedef

C
2 years ago
#include <stdio.h> struct Position{ double x; double y; }; typedef struct Position pos; pos Increase(pos position){ position.x++;

24.02.26: get limit&str, print str

C
2 years ago
/* write a prog: user enters input(string), prog will print the input -use malloc -user can enter the limit of the string, when entering -use this limit when invoking malloc -creat a char pointer(not array) */ #include<stdio.h> #include<stdlib.h>

24.02.26 : malloc(sizeof(int)) ← 100: geht

C
2 years ago
#include<stdio.h> #include<stdlib.h> int main() {

24.02.26. mallo, calloc

C
2 years ago
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { //initial mem allocation char *str; str = (char*)malloc(4); //from 4(3+\0): not overflow strcpy(str, "jin"); printf("str = %s, adr of str = %p\n", str, str);

24.02.25. malloc, free

C
2 years ago
/* 3개의 문자(각 최대 20자)가 저장될 2차원 배열을 힙에 할당한다.(최대 각 20자) 사용자로부터 입력을 받는다 입력된 순서대로 출력한다 */ #include <stdio.h> #include <string.h> #include <stdlib.h>

24.02.25. malloc()

C
2 years ago
#include <stdio.h> #include <stdlib.h> #include <string.h> char *readStr(void); int main() { char *strPtr; strPtr = readStr(); if(strPtr != NULL) { printf("message you entered: %s\n", strPtr);

24.02.25. const: copy array, show arr element

C
2 years ago
#include <stdio.h> void copyArr(int *src, int *dest); void showArrElem(int *arr); int main() { int source[] = {100, 200, 300, 400, 500}; int result[5]; copyArr(source, result); showArrElem(result);

24.02.25. ptr arithmetic, const modifier

C
2 years ago
/******** to write :a prog that calculates the len of str -take as a prmtr a const char ptr -use ptr arithmetic(++) -use while loop -subtract two ptrs -return int *********/

24.02.21. converting strings: strtod, strtof

C
2 years ago
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> int main() { printf("practice1: 1st method of strtod\n"); const char *str = "123.456xzy"; char *endPtr; double numb = strtod(str, &endPtr);

24.02.21. converting strings: toupper, tolower

C
2 years ago
#include <stdio.h> #include <ctype.h> void convertToUpper(char *str) { while (*str) { *str = toupper((unsigned char) *str); str++; } }

24.02.21. string analyzing function : isalpha, isdigit, ispunct

C
2 years ago
#include <stdio.h> #include <string.h> #include <ctype.h> #define LENGTH 100 void getInput(char *arr); int main() { char buff[LENGTH];

24.02.21. tokenizing, strtok

C
2 years ago
#include <stdio.h> #include <string.h> int main() { printf("practice3: tokenizing\n"); char strArr[] = "fun, cool, sexy"; const char delimiters[] = ", ."; //functions the same without . char *token = strtok(strArr, delimiters); while( token != NULL ) {

24.02.21. strch, strstr practice

C
2 years ago
/* EDCXBS35 This example finds the first occurrence of the character p in "computer program". */ #include <stdio.h> #include <string.h> #define SIZE 40 int main(void)

24.02.21. strcspn practice

C
2 years ago
#include <stdio.h> #include <string.h> #define SIZE 40 int main() { char string[ SIZE ] = "It is codes"; char * substring = "cab";

24.02.21. sorts strings using bubble sort

C
2 years ago
#include <stdio.h> #include <string.h> #define MAX_LENGTH 50 void getInput(char inputArr[][MAX_LENGTH], int inputSize); void bubbleSort(char inputArr[][MAX_LENGTH], int inputSize); int main() { int size = 3;

24.02.19. string fuctions with fgets, sscanf

C
2 years ago
#include <stdio.h> #include <string.h> //strcpy #define MAX_LENGTH 100 void bubbleSort(char userArr[][MAX_LENGTH], int size); int main() { char arr[MAX_LENGTH]; char numb1[MAX_LENGTH], numb2[MAX_LENGTH], numb3[MAX_LENGTH]; printf("enter three numbers in alphabets: \n");

24.02.16. sorts strings using bubble sort

C
2 years ago
/*a program that sorts the strings of an array using a bubble sorts -use strcmp, strcpy, bubblesorting -input number of strings: 3 -input string : zero one two -output string: one two

24.02.16. pointer basics

C
2 years ago
/* creat, initialize, assign, access a pointer a program that creats an int var. with a hard-coded value. assign that var's adr to a pointer var. -display as output : 1.the adr of the ptr 2.the value of the ptr 3.the value of what the ptr is pointing to */ #include <stdio.h>

24.02.16. char string/reverse order

C
2 years ago
#include <stdio.h> #include <string.h> #define MAX_LENGTH 100 void reverse(char *userString); int main() { char userWord[MAX_LENGTH]; printf("Enter a word: \n");