Captain
Rain Bow
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?
Daulet
Daulet
Ludovic 'Archivist'
Лазиз
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 ?
Andrii
Richard Luo 🐱
Jahongir
when do you use void in a class?
Naveen
Jahongir
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
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.
d is pointing to nowhere, and its null
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
A
A
Divyanshi
Divyanshi
Hmm
Divyanshi
Okay
Thanks!
Safwan
How to input only alphanumeric and space in a string in c?
A
Divyanshi
Safwan
HaiNahi
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?
klimi
klimi
Dinuka
if statement?
I remove do while and try to implement if statment. But it didn't work 🤔
klimi
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"
Anonymous
Лазиз
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);
}
Daulet
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
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
Even with a teacher, it's the whole variety of ways how to teach, and there are things like "we are doing it now like this, in reality we will do it the proper way", or "let's start with C first"
Pavel
For me it feels like it may be better to learn Java/C# as the first language, and then switch to C++
christian
christian
Ludovic 'Archivist'
christian
Ludovic 'Archivist'
Rain Bow
But for really best performance in software engineering u can try macbook
pka
okaynoted. thankyou for the suggestion rain ☺️
Rain Bow
pka
university kebangsaan malaysia
klimi
Anonymous
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'
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