[Beginner] Call all functions from main() or jump to functions from within functions?

Context\
I have been learning C as a hobby since autum 2025 because I am intrigued by computers. I have mainly been using Bro Code’s tutorial and PDF The C Programming Language (Second Edition), although I’m too much of a beginner to understand all of the latter material. There’s not really much more to it. I don’t really have any concrete goals with learning C, but I thought it could be a good first step into the world of programming and for now, I just really enjoy coding. In the future, I’d like to learn assembly language and then finally (?) program some CPU.

Background\
When I realized how I can use for loops to go through strings and how I can then manipulate certain portions of said string, I realized that I can play around with it to allow a user to modify (here, “trim") any given text. Good fun!

In this particular case, I focused on practicing separating the program into as specific and small functions as possible.

Questions\
1) Should I or could I call the next function from within the previously called function, as opposed to listing them all in main() as I have done below? My guess is that listing them all in main() gives the reader a better overview of the flow, as opposed to having to look into each separate function to find out what’s connecting to what?

2) I believe that the only variable that really needs to be global is the “input”, since so many functions need to be able to access it. What are the pros and cons of using local variables where possible?

CODE #include <stdio.h> #include <string.h> //Function declarations void promptchoice_main(void); void promptchoice_main_again(void); void promptinput(void); void promptchoice_trim(void); void executechoice(char choice_trim); void trimnumbers(void); void trimwhitespace(void); void trimletters(void); void trimspecial(void); void specifyspecial(void); void printresult(char input[]); //Global variables char choice_main = 0x00; char choice_trim = 0x00; char choice_detail = 0x00; char choice_special = 0x00; char input[1000] = ""; char previous_input[1000] = ""; //Remove specific numbers, letters, punctuation or whitespace characters from input. int main() { printf("\nWelcome! This program trims text by removing unwanted characters.\n"); while (1) { if (strlen(previous_input) == 0) { // Check for previously trimmed text in memory. promptchoice_main(); if (choice_main == 'E') { break; } if (choice_main == 'T') { promptinput(); promptchoice_trim(); executechoice(choice_trim); printresult(input); } } else { promptchoice_main_again(); if (choice_main == 'E') { break; } if (choice_main == 'T') { promptinput(); promptchoice_trim(); executechoice(choice_trim); printresult(input); } else if (choice_main == 'P') { sprintf(input, "%s", previous_input); printf("\nYou are trimming previously trimmed text: %s\n", input); promptchoice_trim(); executechoice(choice_trim); printresult(input); } } } printf("\nGoodbye!\n"); return 0; } //Function definitions void promptchoice_main(void) { while (1) { printf("\nPress T and ENTER to trim text or E and ENTER to exit: "); scanf("%c", &choice_main); while (getchar() != '\n') {} if (choice_main == 'T' || choice_main == 'E') { break; } else { printf("\nInvalid input!\n"); } } return; } void promptchoice_main_again(void) { while (1) { printf("\nPress T and ENTER to trim new text, P and ENTER to trim previously trimmed text or E and ENTER to exit: "); scanf("%c", &choice_main); while (getchar() != '\n') {} if (choice_main == 'T' || choice_main == 'P' || choice_main == 'E') { break; } else { printf("\nInvalid input!\n"); } } return; } void promptinput(void) { printf("\nEnter the text that you would like to trim and press ENTER: "); fgets(input, sizeof input, stdin); input[strlen(input) - 1] = '\0'; return; } void promptchoice_trim(void) { while (1) { printf("\nWhat would you like to trim?\n1) Numbers (1, 2, 3...)\n2) Whitespace (space, tab or newline) \n3) Letters (A,B,C... a,b,c...)\n4) Special characters (!,?, . , ...)\nType one of the above numbers and press ENTER: "); scanf("%c", &choice_trim); while (getchar() != '\n') {} if (choice_trim >= 0x31 && choice_trim <= 0x34) { break; } // Only accept 1 through 4. else { printf("\nInvalid choice!\n"); } } return; } void executechoice(char choice_trim) { switch (choice_trim) { case 0x31: trimnumbers(); // 123 etc break; case 0x32: trimwhitespace(); // space, tab, newline break; case 0x33: trimletters(); // ABC..., abc... break; case 0x34: trimspecial(); // ! ? , . etc. break; } return; } void trimnumbers(void) { int n = 0; for (n = strlen(input) - 1; n >= 0; n--) { if (input[n] >= 0x30 && input[n] <= 0x39) { input[n] = 0x18; } } return; } void trimwhitespace(void) { while (1) { printf("\nType S to trim SPACE, T to trim TAB, N to trim NEWLINE or A to trim all whitespace: "); scanf("%c", &choice_detail); while (getchar() != '\n') {} if (choice_detail == 'S' || choice_detail == 'T' || choice_detail == 'A') { break; } else { printf("\nInvalid input!\n"); } } int n = 0; for (n = strlen(input) - 1; n >= 0; n--) { if (choice_detail == 'S') { if (input[n] == 0x20) { input[n] = 0x18; } } // space else if (choice_detail == 'T') { if (input[n] == 0x09) { input[n] = 0x18; } } // tab else if (choice_detail == 'N') { if (input[n] == 0x0A) { input[n] = 0x18; } } // newline else if (choice_detail == 'A') { if (input[n] == 0x20 || input[n] == 0x09 || input[n] == 0x0A) { input[n] = 0x18; } } } return; } void trimletters(void) { while (1) { printf("\nType U to trim uppercase letters, L to trim lowercase letters or A to trim all letters: "); scanf("%c", &choice_detail); while (getchar() != '\n') {} if (choice_detail == 'U' || choice_detail == 'L' || choice_detail == 'A') { break; } else { printf("\nInvalid input!\n"); } } int n = 0; for (n = strlen(input) - 1; n >= 0; n--) { if (choice_detail == 'U') { if (input[n] >= 0x41 && input[n] <= 0x5A) { input[n] = 0x18; } } // Uppercase else if (choice_detail == 'L') { if (input[n] >= 0x61 && input[n] <= 0x7A ) { input[n] = 0x18; } } // Lowercase else if (choice_detail == 'A') { if (input[n] >= 0x41 && input[n] <= 0x5A || input[n] >= 0x61 && input[n] <= 0x7A ) { input[n] = 0x18; } } } return; } void trimspecial(void) { while (1) { printf("\nType A to trim all special characters or S to specify which character to remove: "); scanf("%c", &choice_detail); while (getchar() != '\n') {} if (choice_detail == 'A' || choice_detail == 'S') { break; } else { printf("\nInvalid input!\n"); } } int n = 0; for (n = strlen(input) - 1; n >= 0; n--) { if (choice_detail == 'A') { if (input[n] >= 0x21 && input[n] <= 0x2F || input[n] >= 0x3A && input[n] <= 0x40 || input[n] >= 0x5B && input[n] <= 0x60 || input[n] >= 0x7B && input[n] <= 0x7E) { input[n] = 0x18; } } // All whitespace } if (choice_detail == 'S') { specifyspecial(); } // Let user specify character. return; } void specifyspecial(void) { while (1) { printf("\nEnter special character to trim and press ENTER: "); scanf("%c", &choice_special); while (getchar() != '\n') {} if (choice_special >= 0x21 && choice_special <= 0x2F || choice_special >= 0x3A && choice_special <= 0x40 || choice_special >= 0x5B && choice_special <= 0x60 || choice_special >= 0x7B && choice_special <= 0x7E) { break; } else { printf("\nNot a special character!\n"); } } int n = 0; for (n = strlen(input) - 1; n >= 0; n--) { if (input[n] == choice_special) { input[n] = 0x18; } } return; } void printresult(char input[]) { printf("\nTrimmed text:\n\n%s\n", input); sprintf(previous_input, "%s", input); // Save trimmed text for reuse. return; } //TODO //Create error handling when trimming non existing characters. //Replace characters (uppercase/lowercase, user selected, etc).
@da_667 venv is somewhat confusing but it does work, solves dep issues but i hope they can improve #variables

How TypeScript Infers Type Variables, by (not on Mastodon or Bluesky):

https://norswap.com/typescript-type-variable-inference/?ref=frontenddogma.com

#typescript #variables

norswap · How TypeScript infers type variables

Dear bash experts,

I came across a script today that stubbornly did this for like 30 variables:

declare -rx FOO="${FOO:-}"
declare -rx BAR="${BAR:-}"
...

(So the variable left of the equation sign is the same as the one inside the curly braces. There is only a ":-" after it which assigns it an (empty?) default value, in case it is unset)

Can anyone explain what the reason for that could be? Exporting variables that might (or not) be unset/undefined? Making sure they have an empty value?

Thanks in advance!

#bash #unix #linux #shell #variables #homelab #

Lazarus – ways extract values from an enumeration

Hello, guys! We're continuing to master Lazarus. It's a wonderful programming language similar to Delphi. There's a data type called an enumeration. And sometimes we want to extract values from it. Here's a funny question: How do we do this? We'll look at that today.

https://dimalinkeng.blogspot.com/2026/05/lazarus-ways-to-extract-values-from.html

#delphi #lazarus #enum #enumeration #getvalues #learning #code #moderndelphi #strings #variables

bourne_again_shell 1978

Bash 1978

This is a short book which you may read if you work on Open Source systems with bash installed as the default sh

Some Quotes

Variable names begin with a letter and consist of letters, digits, and underscores. Shell variables may be given values when a shell procedure is invoked. An argument to a shell procedure of the form name = value causes value to be assigned to name before execution of the procedure begins. The value of name in the invoking shell is not affected. Such names are sometimes called keyword parameters. Keyword parameters may also be exported from a procedure by saying, for example, export user box Modification of such variables within the called procedure does not affect the values in the calling procedure. (It is generally true of a UNIX process that it may not modify the environment of its caller without explicit request on the part of that caller. Files and shared file descriptors are the exceptions to this rule.) A name whose value is intended to remain constant throughout a procedure may be declared readonly.

Page 13

Because this is a light book I will hunt for more in depth books on shells

sources

https://en.wikipedia.org/wiki/Bash_(Unix_shell)

https://archive.org/details/bstj57-6-1971

#bash #bourne #again #shell #Open #Source #shell #programming #variables

Point-Free Logic Programming

2 comments

Lobsters

Продуктовая колористика: сборка тоновых растяжек в примитивах дизайн-систем

Проблема Как тоновые растяжки решают проблему Тоновые растяжки в Primitives (три уровня переменных) Некорректные методы сборки Корректные методы сборки Лайфхаки Выводы Дальше — больше

https://habr.com/ru/articles/1030018/

#колористика #дизайн #дизайнсистема #дизайн_интерфейсов #дизайн_сайтов #растяжки #тоновые_растяжки #подбор_цветов #variables #primitives

Продуктовая колористика: сборка тоновых растяжек в примитивах дизайн-систем

Проблема Как тоновые растяжки решают проблему Тоновые растяжки в Primitives (три уровня переменных) Некорректные методы сборки  Корректные методы сборки Лайфхаки Выводы Проблема У многих...

Хабр
Testing Font Scaling For Accessibility With Figma Variables — Smashing Magazine

Accessibility works best when it blends into everyday design workflows. The goal isn’t a big transformation, but simple work processes that fit naturally into a team’s routine. With Figma variables, testing font size increases becomes part of the design flow itself, making accessibility feel almost inevitable rather than optional.

Smashing Magazine

Дизайн-токены: полный гайд по архитектуре и неймингу c примерами и задачками

Дизайн-токены — это язык, понятный как дизайнерам, так и разработчикам. Без него продукт получается разрозненным и неповоротливым. Токены и правильный нейминг помогают создавать новые разделы быстрее, а дизайнерам больше думать о сценариях и создавать визуал в рамках продукта, а не заниматься рутиной. Если в вашем коде и макетах до сих пор живут значения типа #0055FF — вы копите технический долг, ведь если понадобится изменить этот цвет на другой, придется менять и все компоненты, где используется это значение. А про разные темы вообще можете забыть... В конце статьи будут ссылки на доп. материалы из реальных дизайн-систем, откуда я брал информацию. Изучить тему

https://habr.com/ru/articles/1012980/

#дизайнсистема #дизайн #figma #tokens #токены #дизайнтокены #variables #design_system

Дизайн-токены: полный гайд по архитектуре и неймингу c примерами и задачками

Дизайн-токены — это язык, понятный как дизайнерам, так и разработчикам. Без него продукт получается разрозненным и неповоротливым. Токены и правильный нейминг помогают создавать новые разделы быстрее,...

Хабр