comit 1
parent
4ef951ab82
commit
b8e2bbf3c7
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "macos-clang-x64",
|
||||||
|
"includePath": [
|
||||||
|
"${workspaceFolder}/**"
|
||||||
|
],
|
||||||
|
"compilerPath": "/usr/bin/clang",
|
||||||
|
"cStandard": "${default}",
|
||||||
|
"cppStandard": "${default}",
|
||||||
|
"intelliSenseMode": "macos-clang-x64",
|
||||||
|
"compilerArgs": [
|
||||||
|
""
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": 4
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "clang++ - Build and debug active file",
|
||||||
|
"type": "lldb",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${fileDirname}/${fileBasenameNoExtension}",
|
||||||
|
"args": [
|
||||||
|
"-arg1",
|
||||||
|
"-arg2"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "C/C++ Runner: Debug Session",
|
||||||
|
"type": "lldb",
|
||||||
|
"request": "launch",
|
||||||
|
"args": [],
|
||||||
|
"cwd": "/Users/andreypilipenko/STUDY/code/my_c",
|
||||||
|
"program": "/Users/andreypilipenko/STUDY/code/my_c/build/Debug/outDebug"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -0,0 +1,62 @@
|
|||||||
|
{
|
||||||
|
"C_Cpp_Runner.cCompilerPath": "clang",
|
||||||
|
"C_Cpp_Runner.cppCompilerPath": "clang++",
|
||||||
|
"C_Cpp_Runner.debuggerPath": "lldb",
|
||||||
|
"C_Cpp_Runner.cStandard": "",
|
||||||
|
"C_Cpp_Runner.cppStandard": "",
|
||||||
|
"C_Cpp_Runner.msvcBatchPath": "",
|
||||||
|
"C_Cpp_Runner.useMsvc": false,
|
||||||
|
"C_Cpp_Runner.warnings": [
|
||||||
|
"-Wall",
|
||||||
|
"-Wextra",
|
||||||
|
"-Wpedantic",
|
||||||
|
"-Wshadow",
|
||||||
|
"-Wformat=2",
|
||||||
|
"-Wcast-align",
|
||||||
|
"-Wconversion",
|
||||||
|
"-Wsign-conversion",
|
||||||
|
"-Wnull-dereference"
|
||||||
|
],
|
||||||
|
"C_Cpp_Runner.msvcWarnings": [
|
||||||
|
"/W4",
|
||||||
|
"/permissive-",
|
||||||
|
"/w14242",
|
||||||
|
"/w14287",
|
||||||
|
"/w14296",
|
||||||
|
"/w14311",
|
||||||
|
"/w14826",
|
||||||
|
"/w44062",
|
||||||
|
"/w44242",
|
||||||
|
"/w14905",
|
||||||
|
"/w14906",
|
||||||
|
"/w14263",
|
||||||
|
"/w44265",
|
||||||
|
"/w14928"
|
||||||
|
],
|
||||||
|
"C_Cpp_Runner.enableWarnings": true,
|
||||||
|
"C_Cpp_Runner.warningsAsError": false,
|
||||||
|
"C_Cpp_Runner.compilerArgs": [],
|
||||||
|
"C_Cpp_Runner.linkerArgs": [],
|
||||||
|
"C_Cpp_Runner.includePaths": [],
|
||||||
|
"C_Cpp_Runner.includeSearch": [
|
||||||
|
"*",
|
||||||
|
"**/*"
|
||||||
|
],
|
||||||
|
"C_Cpp_Runner.excludeSearch": [
|
||||||
|
"**/build",
|
||||||
|
"**/build/**",
|
||||||
|
"**/.*",
|
||||||
|
"**/.*/**",
|
||||||
|
"**/.vscode",
|
||||||
|
"**/.vscode/**"
|
||||||
|
],
|
||||||
|
"C_Cpp_Runner.useAddressSanitizer": false,
|
||||||
|
"C_Cpp_Runner.useUndefinedSanitizer": false,
|
||||||
|
"C_Cpp_Runner.useLeakSanitizer": false,
|
||||||
|
"C_Cpp_Runner.showCompilationTime": false,
|
||||||
|
"C_Cpp_Runner.useLinkTimeOptimization": false,
|
||||||
|
"C_Cpp_Runner.msvcSecureNoWarnings": false,
|
||||||
|
"files.associations": {
|
||||||
|
"my_funcs.h": "c"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"type": "cppbuild",
|
||||||
|
"label": "C/C++: clang сборка активного файла",
|
||||||
|
"command": "/usr/bin/clang",
|
||||||
|
"args": [
|
||||||
|
"-fcolor-diagnostics",
|
||||||
|
"-fansi-escape-codes",
|
||||||
|
"-g",
|
||||||
|
"${file}",
|
||||||
|
"-o",
|
||||||
|
"${fileDirname}/${fileBasenameNoExtension}"
|
||||||
|
],
|
||||||
|
"options": {
|
||||||
|
"cwd": "${fileDirname}"
|
||||||
|
},
|
||||||
|
"problemMatcher": [
|
||||||
|
"$gcc"
|
||||||
|
],
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
},
|
||||||
|
"detail": "Задача создана отладчиком."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Open Terminal",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "osascript -e 'tell application \"Terminal\"\ndo script \"echo hello\"\nend tell'",
|
||||||
|
"problemMatcher": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": "2.0.0"
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "./my_funcs.h"
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
double A[256];
|
||||||
|
scan_array(A, 3, "lf");
|
||||||
|
print_array(A, 3, "%l");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@ -0,0 +1,170 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "my_funcs.h"
|
||||||
|
|
||||||
|
int scan_array(void * p_array, size_t size, char * specifier)
|
||||||
|
{
|
||||||
|
int scan_el_cnt = 0;
|
||||||
|
|
||||||
|
size_t spec_size = strlen(specifier);
|
||||||
|
if (spec_size == 1)
|
||||||
|
{
|
||||||
|
switch (specifier[0])
|
||||||
|
{
|
||||||
|
case 'c':
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < size; i++)
|
||||||
|
{
|
||||||
|
if (scanf("%c", ((char *) p_array) + i))
|
||||||
|
scan_el_cnt++;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case 'd':
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < size; i++)
|
||||||
|
{
|
||||||
|
if (scanf("%d", ((int *) p_array) + i))
|
||||||
|
scan_el_cnt++;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case 'f':
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < size; i++)
|
||||||
|
{
|
||||||
|
if (scanf("%f", ((float *) p_array) + i))
|
||||||
|
scan_el_cnt++;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (spec_size == 2)
|
||||||
|
{
|
||||||
|
if (specifier[0] == 'l')
|
||||||
|
{
|
||||||
|
switch (specifier[1])
|
||||||
|
{
|
||||||
|
case 'd':
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < size; i++)
|
||||||
|
{
|
||||||
|
if (scanf("%ld", ((long *) p_array) + i))
|
||||||
|
scan_el_cnt++;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case 'f':
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < size; i++)
|
||||||
|
{
|
||||||
|
if (scanf("%lf", ((double *) p_array) + i))
|
||||||
|
scan_el_cnt++;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return scan_el_cnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
int print_array(void * p_array, size_t size, char * specifier)
|
||||||
|
{
|
||||||
|
size_t spec_size = strlen(specifier);
|
||||||
|
if (spec_size > 1 && specifier[0] == '%')
|
||||||
|
{
|
||||||
|
switch (specifier[1])
|
||||||
|
{
|
||||||
|
case 'c':
|
||||||
|
{
|
||||||
|
char * new_p = p_array;
|
||||||
|
for (unsigned int i = 0; i < size; i++)
|
||||||
|
printf(specifier, new_p[i]);
|
||||||
|
} break;
|
||||||
|
case 'd':
|
||||||
|
case 'x':
|
||||||
|
case 'X':
|
||||||
|
{
|
||||||
|
int * new_p = p_array;
|
||||||
|
for (unsigned int i = 0; i < size; i++)
|
||||||
|
printf(specifier, new_p[i]);
|
||||||
|
} break;
|
||||||
|
case 'f':
|
||||||
|
{
|
||||||
|
float * new_p = p_array;
|
||||||
|
for (unsigned int i = 0; i < size; i++)
|
||||||
|
printf(specifier, new_p[i]);
|
||||||
|
} break;
|
||||||
|
case 'e':
|
||||||
|
{
|
||||||
|
double * new_p = p_array;
|
||||||
|
for (unsigned int i = 0; i < size; i++)
|
||||||
|
printf(specifier, new_p[i]);
|
||||||
|
} break;
|
||||||
|
case 'l':
|
||||||
|
{
|
||||||
|
if (spec_size > 2)
|
||||||
|
{
|
||||||
|
switch (specifier[2])
|
||||||
|
{
|
||||||
|
case 'd':
|
||||||
|
case 'x':
|
||||||
|
case 'X':
|
||||||
|
{
|
||||||
|
long * new_p = p_array;
|
||||||
|
for (unsigned int i = 0; i < size; i++)
|
||||||
|
printf(specifier, new_p[i]);
|
||||||
|
} break;
|
||||||
|
case 'f':
|
||||||
|
{
|
||||||
|
double * new_p = p_array;
|
||||||
|
for (unsigned int i = 0; i < size; i++)
|
||||||
|
printf(specifier, new_p[i]);
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_array_table(void * p_array, size_t size, char * specifier, int colomn)
|
||||||
|
{
|
||||||
|
size_t spec_size = strlen(specifier);
|
||||||
|
if (spec_size == 1 && specifier[0] == 'e')
|
||||||
|
{
|
||||||
|
float * new_p = p_array;
|
||||||
|
for (unsigned int i = 0; i < size; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < colomn; i++)
|
||||||
|
{
|
||||||
|
if (i + j + 2 > size)
|
||||||
|
return;
|
||||||
|
printf("%5e ", new_p[i]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (spec_size == 2 && specifier[0] == 'l' && specifier[1] == 'd')
|
||||||
|
{
|
||||||
|
long * new_p = p_array;
|
||||||
|
for (unsigned int i = 0; i < size; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < size / colomn; j++)
|
||||||
|
{
|
||||||
|
if (i + j + 1 > size)
|
||||||
|
return;
|
||||||
|
printf("%10ld ", *(new_p + i + j));
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue