Anonymous
Neither of them worked. At least std::views does not work
std::views is a library feature and not a language feature. So if clang can't compile it with libc++, you can ask clang to compile the code with libstdc++ (the gnu standard library implementation that gcc uses). This is assuming that clang version you are using supports concepts. The command line option for clang to choose a standard library implementation is -stdlib=<libc++ or libstdc++>. A better option would be to use rangesv3
Лазиз
Hi everyone! This is my task Create src/s21_string.h and src/s21_string.c files and add declaration and definition of the s21_strlen function to them. declaration in s21_string.h ################### #include <stdio.h> #include <stdlib.h> int s21_string(char str); ################### definition in s21_string.c ################### int s21_strlen(char *s){ char *sc = s; while (*sc != '\0') { sc++; } return sc - s; } ################### If its possible can you check please?
Лазиз
CONTINUATION! Create a test program, src/s21_string_test.c, that should include the s21_strlen_test function for checking the s21_strlen function with a set of test data (minimum 3): normal values, abnormal values, boundary values, etc. For each test, the input, output, and test result (SUCCESS/FAIL) must be output to stdout. Add the launch of this function to main. #include "s21_string.h" void s21_strlen_test(int length); int main () { s21_strlen_test(s21_string("Hello World!")); s21_strlen_test(s21_string("H")); //abnormal values ??? s21_strlen_test(s21_string("")); // boundary values ??? return 0; } void s21_strlen_test(int length){ if (length > 0){ printf("SUCCESS"); } else { printf("FAIL"); } } Can you explain or give the examples for abnormal and boundary values ?
Jahongir
when do you use void in a class?
Naveen
Dinuka
Can anyone help meto get sample code for this scenerio This is regarding student information saving and display system Data structure Student name Student id Marks These data need to be get as input and save them to txt file. And also able to edit and delete. Does anyone have sample code writed in these scenario?
Anonymous
printf("Type([L]ight,[B]lend): "); scanf("%s", coffee_type1); printf("Type:%s\n", coffee_type1); if(strncmp(*coffee_type1, 'L' *coffee_type1, 'l') == 0){ Light1 = 1; Blend1 = 0; } else if(strncmp(*coffee_type1, 'B' *coffee_type1, 'b') == 0){ Light1 = 0; Blend1 = 1; }
Anonymous
what is the correct way to do this ?
Anonymous
Have a good day, how to access enum members within a struct with a pointer, is it possible? my example: ========== #include <stdio.h> typedef enum Week_t { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday } week; typedef struct Day_t { week wk; } day; int main (void) { day *d; int get_day = d->wk = Thursday; printf("%d\n", get_day); return 0; } I've got segmentation fault as output.
Dima
initialize it d = (day*) malloc(sizeof(day)) and dont forget to free(d) it or just do not use heap allocation
Anonymous
#neko_code, It Works, Thanks a lot, I very appreciate your help :D
Divyanshi
Can anyone find the problem with the following code? Convert decimal to binary: int main (){ int a,b; cin>>a; int s=0; int c=1; while (a>0){ b=a%2; s=s+(b*c); a=a/2; c=c*10; } cout<<s; }
Divyanshi
My three test cases are coming wrong but I am unable to find the problem with my code
Divyanshi
Pls anyone tell
olli
Pls anyone tell
which numbers did you test it with? This method only works for small numbers because in the binary representation you need more digits in comparison to a decimal representation. Ideally you should create a string representation of the number
Divyanshi
Take array to Store binary bits
Ohk Is their any other way without using arrays?
olli
Ohk Is their any other way without using arrays?
you could just print the single digits without storing the actual result. However using an array would be beneficial
Divyanshi
Hmm
Divyanshi
Okay Thanks!
Safwan
How to input only alphanumeric and space in a string in c?
A
How to input only alphanumeric and space in a string in c?
In c++ isaplha is function you can use that and compare string character with spaces
A
No i need to implement in c
Compare character and with ASCII values or directly with character
Ludovic 'Archivist'
https://archivist.nekoit.xyz/fast-logging/
Dinuka
void write_book() { system("cls"); int more_or_main; fp.open("book.dat",ios::out|ios::app); do { bk.create_book(); fp.write((char*)&bk,sizeof(book)); cout<<"\nPress 1 to add more books."; cout<<"\nPress 2 to return to main menu.\n"; cout<<"Enter: "; cin>>more_or_main; }while(more_or_main == 1); fp.close(); } Here is the part of my code I need it to go main_menu to when press 2. How can i do it?
Dinuka
what do you mean by "go main_menu"?
Its a function i create. Once i press 2 i need it to go main_menu(); How can i arrange the code?
Dinuka
if statement?
I remove do while and try to implement if statment. But it didn't work 🤔
Anonymous
c++ is hard
Ludovic 'Archivist'
c++ is hard
That's an understatement, I have done C++ for more than 10 years and still I learn niche details every other week
Jose
The keyword here is "niche"
Лазиз
hello! explain why the pointer to the next element is underlined with wavy (red) lines in visual studio? struct node { struct door struct node *next; }; struct node* init(struct door* door){ struct node *lst; lst = (struct node*)malloc(sizeof(struct node)); lst-> = door; lst->next = NULL; return (lst); }
pka
hai , i need help . which one is better for programming student , ryzen 5 5500u or intel 5 ?
pka
i going to further my studies in software engineering , really need advice . thanks in advance
Ludovic 'Archivist'
Would you suggest c++ as beginner friendly ?
Both yes and no: Yes because just getting started is easy, you can learn concepts in isolation one by one, you can learn the importance of abstraction, you can learn the way CPUs work, design patterns, memory, operating systems... But also no because if you learn without a teacher you will try to learn everything at the same time and do wacky things because they work
Pavel
For me it feels like it may be better to learn Java/C# as the first language, and then switch to C++
christian
For me it feels like it may be better to learn Java/C# as the first language, and then switch to C++
I'd honestly agree, but that's because I haven't written any C++ yet
Ludovic 'Archivist'
It's nice to do wacky things and get called out for them so you don't do em again Some of us don't have the liberty of having someone by your side as you learn
The main issue is that without a mentor or something like that, getting called on the wacky things doesn't happen
Ludovic 'Archivist'
Rain Bow
hai , i need help . which one is better for programming student , ryzen 5 5500u or intel 5 ?
Hy too syafikah for me i will chosse ryzen 5 5500u its cool and best performance than intel core i5
Rain Bow
But for really best performance in software engineering u can try macbook
pka
okaynoted. thankyou for the suggestion rain ☺️
Rain Bow
okaynoted. thankyou for the suggestion rain ☺️
Alright which university that u study ?
pka
university kebangsaan malaysia
klimi
But for really best performance in software engineering u can try macbook
and good luck running some of the softwares on it
Anonymous
Would you do rather python or rust or c# or Haskell or go
Anonymous
No python for me that is for sure
Ludovic 'Archivist'
What would you suggest for beginner instead of c++ ?
I would say C# (with Microsoft's tutorials, they are okay-ish to get started on making small applications), or maybe just C (with a good book on the topic like Modern C)
Ludovic 'Archivist'
Or for just some getting started (for like the first month only) Blitz3D, makes things fun and it is a pretty simple language with literally everything in the doc shipped in the IDE
Anonymous
There is just one problem with c#
Anonymous
I'm running linux
Ludovic 'Archivist'
Ludovic 'Archivist'
Linux and C go hand in hand like beer and crisps
Anonymous
Do you also program in other languages?
Ludovic 'Archivist'
Oh, another one would be Elixir
Ludovic 'Archivist'
and there is a huge sale of books on Elixir on humble bundle
Ludovic 'Archivist'
Do you also program in other languages?
I use C, C++, C#, Elixir, Erlang, Javascript, Awk, R, and some others on a regular basis