Pavel
Shuhash
Is there any inbuilt Library function to Remove space in the string
Anonymous
or remove the spaces if it's a std::string, I guess
Shuhash
Anonymous
You know what, you can use this:
Anonymous
https://stackoverflow.com/questions/83439/remove-spaces-from-stdstring-in-c
Mystic
Can anyone tell what should I do first
Mystic
dsa or c++
Shuhash
Anonymous
This is exactly what happens when you use std::greater<>. It defaults to std::greater<void>
_
can one declare a string data type in c as: typedef char* string; ? Is there another way besides declaring an array of characters?
Anonymous
Anonymous
char* gives you the right impression that you are using a pointer to an array of chars.
_
_
Anonymous
_
Anonymous
Just make something like what I said.
Anonymous
If you really want abstraction, I am not sure why you don't hop over to c++
Anonymous
Because the standard library there abstracts it with std::string
_
_
Smita
Can anyone tell me how to develop logic for any program in c language
Anonymous
Anonymous
I tried with only T for both a and b, and it seemed to work, so ig that's fine.
But how are T and Q inferred by the compiler? The compiler automatically determines the type of data with which we call comp<>()?
Also, why do we default the template parameter to void, as in
<typename T=void>?
Shouldn't <typename T> be enough, because when we specialize with, say char, we don't need to default T to char.
I specified T and U because that is what std::greater template does. Using two different template types allows more flexibility because that would allow you to compare an int with a float say.
We default the template parameter to void because if we don't then the compiler would complain about us not having supplied a template argument when we specify comp<>. That is a non deduucing context and the compiler can't figure out which specific template argument to instantiate comp with. By specifying void as default, the compiler will use comp<void> specialization when we don't specify the template argument
The compiler is able to deduce T and U because it is a function call and that is a deducible context. Looking at the priority_queue implementation, the compiler knows that operator() method inside comp will be called with 2 integers in your specific case and hence will be able to deduce T and U as both ints.
This deduction can't happen for comp itself (when the default void parameter is not there) because that is what is called a non deducible context in the standard. So in that case we will have to specifically help the compiler and specify comp<int> instead. In the case where void is the default template parameter argument, the compiler always infers comp<> as comp<void>.
Anonymous
Thank you 😊
aishu
#include<stdio.h>
void number(int n){
static int num=7;
printf("num+n=%d",(num+n));
printf("\n");
num=num+2;
}
int main(){
number(5);
number(5);
return 0;
}
/*o/p: num+n=12
num+n=14*/
aishu
Anonymous
Anonymous
Zishan
Help me to solve my problem
Isaac
pls who can give me a guide to c++
Isaac
i am new to the programming language
Isaac
and i just was a detailed guide
Anonymous
suppose you have two sequences for positive integers A[1...n] and B[1...n]. You wish to find the heaviest common subsequence. The heaviest common subsequence between A and B is the subsequence that has the maximum sum of entries. For ex, if A = 2 2 4 8 5 and B = 2 8 4 5 6, then 2 8 5 is the heaviest weight subsequece of A and B.
can someone help me solving this problem. I am unable to build the logic...?
Anonymous
Anonymous
aishu
What is the difference between %p and %u control strings for denoting address of a variable?
aishu
Kweiwen
hi friends, i would like to design an advanced data structure based on DAG, but seems i've encountered some problem:
1. according to the legacy DAG, the node contains only one input and output, how about a node contains multiple inputs and outputs port?
2. what's the corresponding sorting algorithm? i assume the legacy DAG Sort is not compatible with above requirement.
if you know some terms and key words of this kind of design, please kindly share with me! much appreciate.
M. Wahyu
Source for learn embedded system/software ?
Anonymous
#include <iostream>
using namespace std;
// area = (lngth * width);
// peri = 2 * (lngth + width);
class perimeter;
class Area
{
int length;
public:
void setData(void)
{
cout << " entre the value of Length : ";
cin >> length;
}
friend int area(Area, perimeter);
friend void Parameter(Area, perimeter);
};
class perimeter
{
int width;
public:
void setData(void)
{
cout << " enter the value of width : ";
cin >> width;
}
friend void Parameter(Area, perimeter);
friend int area(Area, perimeter);
};
void Parameter(Area A1, perimeter p1)
{
cout << " the parameter is " << 2 * (A1.length + p1.width);
}
int area(Area a, perimeter p1)
{
return (a.length * p1.width);
}
int main()
{
Area a;
perimeter p;
a.setData();
p.setData();
area(a, p);
Parameter(a, p);
}
Anonymous
problem in area function . the function is not returning the value of length * width , if i do cout« length * width it is working but if im doing return length * width it is not working , why ??
}
Anonymous
Anonymous
It seems area returns an int, but you don't save it anywhere
Anonymous
Hello
Anonymous
I have a question as I do the multiplication table from 1 to 10. I'm very busy.
Anonymous
I have this code
Anonymous
Anonymous
and then if u print res
Anonymous
u would get the results
Anonymous
did you mean create a variable and store the area and print the variable
Anonymous
What's the issue right now? you said "area is not returning".
But u don't return it to anything.
Anonymous
You gotta assign some lvalue to it
Anonymous
Anonymous
But i need this form
Anonymous
Side by side
Dima
lol
Anonymous
Anonymous
NagaRaju
Here I'm trying to debug the C code using lldb and clang compiler.
~ $ clang -g clang/strCompare.c -o a
~ $ lldb a
(lldb) target create "a"
Current executable set to '/data/data/com.termux/files/home/a' (arm).
(lldb) b 18
Breakpoint 1: where = amain + 20 at strCompare.c:19:11, address = 0x00001528
(lldb) b 25
Breakpoint 2: where = amain + 80 at strCompare.c:26:9, address = 0x00001564
(lldb) run
error: failed to launch or debug process
(lldb)
I don't understand why debugging process is not starting.
Can anyone explain me where I was wrong ?
Anonymous
Make chmod of this file 775. anyone explain me about this
Dredd
can someone help me in my code it's not taking my inputs
Dredd
#include <iostream>
using namespace std;
struct Employee{
string name;
struct Employee *next;
};
void insert (struct Employee** head, string employee_data){
struct Employee* newEmployee = new Employee;
newEmployee-> name = employee_data;
newEmployee-> next = (*head);
(*head) = newEmployee;
}
void displaylist(struct Employee *employee){
while(employee != NULL){
cout << employee->name << endl;
employee = employee ->next;
}
}
int main() {
struct Employee* head = NULL;
int x;
string name;
cout << "How many Employee you want to add to the list: ";
cin >> x;
for(int i = 0; i<x; i++){
cin >> name;
insert(&head,name);
}
cout << "Name of the Employee: " << endl;
displaylist (head);
return 0;
}
Ster-Devs
Jagadeesh
anyone know how to choose random elements from array ?
Anonymous
Is there a reason you used constant lvalue reference in the first operator function, but rvalue in the second?
In the first operator function, it is const lvalue for a reason. A struct which compares two values should not have to change it. It being a const reference can accept both lvalues and rvalues.
In the 2nd operator, the arguments are not rvalue references. They are universal references which are much more powerful than const lvalue references in that they can be used for perfect forwarding and also be used with both lvalues and rvalues. When you have a template function, making your arguments a universal reference is usually a good idea barring a few cases. The exceptional cases are documented in Scott Meyers' Effective Modern C++.
Anonymous
Anonymous
..Why is the very hard to understand friend function ..🥲🥲
coal