Hsn
Because u hide behind new ?
Hsn
Im more into sbrk anyway ..
Hsn
coal
if i was a memory management enjoyer I'd use C or Rust
coal
coal
if you code thoughtlessly you end with a lot of bugs
%Nikita
%Nikita
It is really good practice to use assert() sometimes just to debug program
%Nikita
It really helps to catch bugs
the best for everyone
// write a program to wirte the charractors and to know the length of it
#include<stdio.h>
int string_length(char a[]) // to calculate the length of it
{
int i=0;
while (a[i] !='\0')
i++ ;
return i;
}
//int swaping()
palindrome(char a [])
{
int i , palindrm=1 ;
for (i=0;i<string_length(a)/2;i++) // caling this loop to get only the half of the length because they are compring bettwen the first part and the end part
if(a[i]!= a[string_length(a)-1-i] ) // n = string_length
{
palindrm =0; //why ?
break ;
}
return palindrm;// it should be either 1 or 0
}
int main()
{
char name[25];
printf("please enter a name that you want to Enter");
gets(name);
printf("length of %s is = %d\n",name , string_length(name));
if(palindrome(name))
printf("s% is palindrome number\n");
else
printf("%s is not palindrome");
}
the best for everyone
i have two functions in this code but only one function is working when i run it
Pedro
how to print mpz_t to binary representation ? I dont find binary specifier
Anonymous
#include <iostream>
using namespace std;
struct student{
string name;
string dept;
int phy;
int chem;
int math;
int oops;
int dbms;
}s1,s2,s3;
void fill(struct student s, string Name, string Dept, int p, int c, int m, int o, int d)
{
s.name = Name;
s.dept = Dept;
s.phy = p;
s.chem = c;
s.math = m;
s.oops = o;
s.dbms = d;
}
void show(struct student s)
{
printf("\n%s\n%s\n%d\n%d\n%d\n%d\n%d",s.name, s.dept, s.phy, s.chem, s.math, s.oops, s.dbms);
}
int percentage(struct student s)
{
return ((s.phy + s.chem + s.math + s.oops + s.dbms)*100)/150;
}
int main()
{
fill(s1, "Riya", "CSAI", 29, 21, 20, 25, 30);
show(s1);
printf("\nPercentage : %d",percentage(s1));
return 0;
}
Anonymous
Help me resolve the error here
the output is incorrect
I don't know where the error is
Anonymous
#include <stdio.h>
#include <string.h>
char username[64], password[64], hostname[64];
int main(int argc, char **argv) {
char result[256];
if (argc != 4 ||
strlen(argv[1]) > sizeof(username) ||
strlen(argv[2]) > sizeof(password) ||
strlen(argv[3]) > sizeof(hostname)) {
fprintf(stderr, "bad arguments\n");
return -1;
}
strcpy(username, argv[1]);
strcpy(password, argv[2]);
strcpy(hostname, argv[3]);
result[0] = 0;
strcat(result, "http://");
strcat(result, username);
strcat(result, ":");
strcat(result, password);
strcat(result, "@");
strcat(result, hostname);
strcat(result, "/");
printf("%s\n", result);
return 0;
}
Anonymous
In this code is there a way to overflow result?
Anonymous
Can someone explain how this answer explains the behaviour of hash map insertion? https://stackoverflow.com/a/51945119/13076508
Sommy
What kind of projects do developers work on in C++ at various product based companies?
Ludovic 'Archivist'
Database engines too
Ludovic 'Archivist'
(my favorite pastime, making database engines in C++)
Ludovic 'Archivist'
Performance can also be improved by giving up on prerequisites such as references preservation, non-power of 2 size, etc etc
Ludovic 'Archivist'
It can be further improved by improvements to locality and by using open-addressing with exponential probing, or by using hybrid addressing
Ludovic 'Archivist'
Robinhood hashing also is pretty good
ʙʀʜᴏᴏᴍ ⑇
Hi
ʙʀʜᴏᴏᴍ ⑇
Programmers...
I am now learning C in vscode
But I have a specific problem... When I run the program file(the code), another file with the same name appears to me, which is has a different form (.exe)
and when I change the code and run again, nothing changes on the terminal
ʙʀʜᴏᴏᴍ ⑇
So I always delete the new file which end in .exe
and run the file again
But I want something to do all that automatically
When I change the code and run it its change the result without deleting the exe file
ʙʀʜᴏᴏᴍ ⑇
Help me now!! Plz
Talula
Help me now!! Plz
Make a batch command if you're in Windows, make a shell command line if you're using Linux.
ʙʀʜᴏᴏᴍ ⑇
Melissa
Hello everyone 👋😄
Chirag
Hlo
Melissa
CALVIN
Please send me diagrams questions to attempt
Diagrams like this👇
*
*
****
Dima
wtf
\Device\NUL
Dima
read the rules
CALVIN
\Device\NUL
#include <stdio.h>
#include <string.h>
char username[64], password[64], hostname[64];
int main(int argc, char **argv) {
char result[256];
if (argc != 4 ||
strlen(argv[1]) > sizeof(username) ||
strlen(argv[2]) > sizeof(password) ||
strlen(argv[3]) > sizeof(hostname)) {
fprintf(stderr, "bad arguments\n");
return -1;
}
strcpy(username, argv[1]);
strcpy(password, argv[2]);
strcpy(hostname, argv[3]);
result[0] = 0;
strcat(result, "http://");
strcat(result, username);
strcat(result, ":");
strcat(result, password);
strcat(result, "@");
strcat(result, hostname);
strcat(result, "/");
printf("%s\n", result);
return 0;
}
strlen return string length without NULL character
\Device\NUL
Just use strncat
Abbas
What should we take first step to learn programming ?
Jatin
Understanding the concepts!
Jamil
#include <stdio.h>
int main()
{
int num1, num2, num3;
printf("Enter 3 number\n");
scanf("%d%d%d", &num1, &num2, &num3);
if(num1>num2 && num1>num3)
{
printf("%d is grater", num1);
}
else if(num2>num1 && num2>num3);
{
printf("%d is grater", num2);
}
else
{
printf("%d is grater", num3);
}
Jamil
this code giving me else error.
Anonymous
Talula
Talula
Leovan
Hello, I need to create dynamic array (filled with the same value) in my class using placement new.
Class T hasn't default constructor and operator=, but has copy constructor (which i use instead of them):
class Array
{
public:
Array(size, T const &value = T()) : size_(size) // use default constructor if exists
{
void * mem = new char[size_ * sizeof(T)]; // allocate memory
T * data_ = new (mem) T(value); // I use copy constructor, but I don't fully understand how placement new doing there, only data_[0] has right value
but this work:
for (size_t i = 0; i != size; ++i)
data_[i] = T(value);
how i can (using placement new) define the whole array? Something like: T * data_ = new (mem) T(value)[size_];
Anonymous
Deleted Account
Hi? Can you recommend what program should I do for my assign task in school. I couldn't think anything simple but complex.
Ludovic 'Archivist'
A CBOR parser and serializer
Ludovic 'Archivist'
It is well documented and took one of my students around 5 hours to do in C++
Ludovic 'Archivist'
Z (forgot to reply)
Deleted Account
Ok, thanks for your suggestion.
Ludovic 'Archivist'
Deleted Account
But can I put atleast 1 loop, if else and switch on it?
Ludovic 'Archivist'
Deleted Account
Thanks 😊
Leovan
ᴹᵒʰᵃᵐᵐᵃᵈ
Hello friends
I have the following problem, Can anyone help me?
main.c:(.text+0x1c0): undefined reference to `__gmpz_init'
main.c:(.text+0x21d): undefined reference to `__gmpz_set_str'
main.c:(.text+0x238): undefined reference to `__gmpz_get_str'
main.c:(.text+0x411): undefined reference to `densenauty'
main.c:(.text+0x4f2): undefined reference to `__gmpz_set_str'
main.c:(.text+0x50d): undefined reference to `__gmpz_get_str'
/tmp/cczSkowd.o:(.data+0x60): undefined reference to `dispatch_graph'
aishu
#include<stdio.h>
int main()
{
int i=1;
for(i=1;i<=3;++i)
{
printf("%d\n",i);
}
while(i<=3)
{
printf("%d\t",i);
++i;
}
}
Can anyone tell why my while loop is not working here
Max
Hi
Leovan
aishu
aishu
\Device\NUL
Anonymous
Anonymous
aishu
ᴹᵒʰᵃᵐᵐᵃᵈ
set your linker flag
I do not know how to do this
I use vs code, can I see a bad educational link, how should I set the link?
Anonymous
i want to sum two large number like 100 digit, 89 digit. so i have to use uint_8.