G.E.N.E
It's because it's an impromptu requirement
My bad for any offense
Talula
G.E.N.E
There a few errors in it
Talula
There a few errors in it
Those are simple syntax errors, you can correct those by compiling and compiler will tell you what they are...
Talula
like it should be "int main()" not "Int main()".
Sachin
vector<vector<int>> adj[]
Sachin
hello can any one tell me how to traverse through
Sachin
vector<vector<int>> adj[]
Sachin
it
Nils
uint32_t do_pixel(unsigned x, unsigned y, unsigned width, unsigned height, unsigned long framecounter) {
float uvx = (float)x / (float)width,
uvy = (float)y / (float)height;
if (fabs(uvx-0.5f) < 0.1f && fabs(uvy-0.5f) < 0.1f) {
return 0xffffff;
} else {
return 0x000000;
}
}
Hey, any idea why this results in a rectangle instead of a circle?
dipan
️Skill
is that possible with C macros to specify new function name in this way (actually it doesn't work)?
#define DEF_CMP_FUNC(cmp_field, func_body) (int cmp_cmp_field_asc(const void *s1, const void *s2) {return func_body}; int cmp_cmp_field_desc(const void *s1, const void *s2) {return cmp_cmp_field_asc(s2, s1)})
solved: use ##cmp_field##
*
Anonymous
if anyone need help in projects like machine learning and Django Flask web development dm me ..
Nils
which constructor is required to return a class instance?
Nils
My current constructors are:
vec();
vec(const vec& o);
template<class... values>
vec(values... vals);
and when returning it tries to call the last one... And obviously fails
shriman_deepak
/*
9) Given a file with numbers separated by spaces in each line. Write a program that reads line by line from this file and prints each line
in ascending numerical order to a file named output.txt. Manage memory dynamically.
*/
shriman_deepak
here how can i scan the file line by line
shriman_deepak
and make array of each line dynamically
shriman_deepak
int main(int argc, char* argv[])
{
FILE *fp = fopen("input.txt","r");
int s = 0;
int t = 0;
int* array = (int*)malloc(s*(sizeof(int)));
int** whole = (int**)malloc(t * (sizeof(int*)));
int n;
char ch;
//while (!feof (file))
while (!feof (fp))
{
while (fscanf(fp,"%c",&ch) != '\n')
{
fscanf(fp,"%d",&n);
s++;
array = (int*)realloc(array,s*(sizeof(int)));
array[s-1] = n;
}
fscanf(fp,"%d",&n);
s++;
array = (int*)realloc(array,s*(sizeof(int)));
array[s-1] = n;
}
for (int i = 0; i < s; i++)
{
printf("%d",array[i]);
}
free(array);
return 0;
}
shriman_deepak
with this code the whole file is getting scanned all together
AlanCcE
Im starting with C coding, and for some reason my VSCODE cannot do #include <cs50.h>, some videos talk about change the include path, but i already did it and its not working, do i need to download something or change somemthin?
AlanCcE
something*
ND
AlanCcE
AlanCcE
Im just trying to sum x + y, these two are input variables
\Device\NUL
ꍏꈤꀸ
What is the fastest solution to find whether string contains some pattern?
Example:
string input = "blah blah blah 1:2:3 blah blah";
string pattern = "%d:%d:%d"; // means i need to find 3 digits separated by :
std::regex is slow and i can't use any 3rd party libs.
\Device\NUL
️Skill
is this code correct?
size_t len = strlen(remain+1);
wchar_t *publisher_name = malloc((len+1)*sizeof(wchar_t));
mbstowcs(publisher_name, remain+1, len);
Anonymous
hi guys
Anonymous
who is prof is C++
Anonymous
I have some question
\Device\NUL
️Skill
️Skill
️Skill
\Device\NUL
I usually use calloc when dealing with heap string because it will initialize the memory region into zero
Avoiding UB when accessing unitialized memory
Fenimoure
I can't find a single tutorial on how to separately declare and define a structure in C++. Please, give me some links if you happen to have them, or tell me how to do this in the PM. Thank you in advance.
\Device\NUL
\Device\NUL
Eh, wait a minute, whats data type of remain ?
\Device\NUL
You should use wcslen instead of strlen to find string length of wchar_t
️Skill
️Skill
Anonymous
Go through all the rules and the links mentioned in this post. Contravening the rules laid out here will result in a warning (least likely) or a ban (most likely).
This group is meant only for C/C++ discussion.
For chitchat of any other kind, go to the Offtopic chat, where anything unrelated to C/C++ programming can be discussed subject to the rules laid out for that group.
For information on learning C/C++, see our list of resources at @Resources
RULES:
1. Only English language is allowed. If you don't speak English, then this group is not for you. Please look elsewhere.
2. This group is meant to be used for C/C++ discussions alone. Assembly language discussions are allowed as well. The moderators' intention is to keep this group clean and to stick to the purpose the group was created for. Hence, questions or discussions about anything else is strictly forbidden. This further means that:
• You should not send useless messages like "Hi"/"Hello", "I'm new here" and similar.
• You should not send useless messages like "Does anyone know XYZ?", "Has anyone used XYZ?". Just ask your question directly.
• You should not ask questions without checking your problem in Google or any other search engine. Doing so will result in a warning. Following this, check the Resources section of this group to see if your question has an answer there.
• You should not ask exams/homework/interviews solutions. This will get you banned.
Asking for something that is there in the pinned message right after joining will get you banned.
3. NSFW content (porn, nudity etc) is not allowed.
4. Religion, politics and ideological topics are forbidden.
5. A little bit of programming related jokes and memes are allowed subject to admin group's discretion.
6. Advertisements of any kind are forbidden. Job postings will not be allowed either. If you are unsure about whether something could be construed as an advertisement, please check with one of the admins before posting the message. Not doing so will result in a ban.
7. Code sharing is encouraged subject to the following rules:
• Try to use markdown formatting.
• For many lines (10+) of code, use a pasting service like Gist, Pastebin, Ubuntu Paste, Hastebin. Don't post walls of code in the chat window. Firstly, it inconveniences others and secondly, you are unlikely to get a response and may even get warned or banned.
• Don't attach photos or videos of your screen. Screenshot captures are ok.
8. No illegal activity. This also means no piracy, no requesting/offering hacking/no posting of compiled executables. This will result in an immediate ban.
9. Respect people's privacy. Don't send private messages to people in this group without taking their permission to do so. Not following this rule will result in an immediate ban.
10. Avoid usernames that affects chat readability.
The group bot Rose offers a lot of readymade responses that can be used when replying to someone. The most commonly used ones are:
• #paste - Display a list of sites where code can be shared.
• #markdown - Learn how to use markdown formatting.
• #res - Post the link to the C/C++ resource collection.
• #meta - Tell someone to get to the point!
• #howtoask - Tell someone how they should ask a question.
• #ot - Tell someone that their question is off-topic and hence must be moved to the OT group.
Fenimoure
Is there any way of declaring structs methods not in the header, but in the cpp file? The struct itself still has to be in the header. I can't find the answer on Google 😱
Anonymous
רז
hi, i am try to writh a code that find Coefficient of equation and the free number when the input by the user is like this: (example: 3*x+4*y=10).
רז
i am trying to use strtok_s without sucsses any one can help?
רז
can share the code
רז
i am using switch and case , this is the code inside the case:
printf("Enter equation 1: ");
getchar();
fgets(strx2, sizeof(strx2), stdin);
double x2 = atof(strtok_s(strx2, "*", &second));
printf("x = %.2f\n", x2);// print makadem of x
double y2 = atof(strtok_s(NULL, "*", &third));
printf("y = %.2f\n", y2);// print makadem of y
printf("\nEnter equation 2: ");
get well the first Coefficient but the second is not well.
רז
tnx !
Ольга
https://onlinegdb.com/fsoWe8fix
Hello, maybe someone knows why this don't work?
I be very grateful for any help
Αλι
answer of this can be found by searching google
Pavel
Hmmm, why is this code incorrect?
https://wandbox.org/permlink/PdMyBLmXr7efdRQ6
I have been getting clang warnings for years in my IDE thinking that I have some old clang version installed that doesn't support structured bindings, but it seems like this is by-design?
Compiles well with gcc and MSVC.
Anonymous
#include<bits/stdc++.h>
using namespace std;
bool chk(char x){
return(!isalnum(x));
}
int main(){
string str = "";
string s = "Amit 12 3 , 13,34,5";
remove_if(s.begin(),s.end(),chk);
cout<<s;
return 0;
}
Anonymous
Amit1231334513,34,5
Anonymous
guys why the o/p is Amit1231334513,34,5 ? my expected output is only Amit1231334513 can any one help ?
ꍏꈤꀸ
Ольга
Good evening, sorry to bother you. I was faced with the task of where to find whether a certain word is present in the structure. That is, the word is specified by the user, and the structure consists of two parameters, author and title. And I need to display the title and author when the user enters the desired word. For example, the input of Bezu, and the structure is given Bezu analysis. That is, there is such and, accordingly, if the input is the word analysis, then there is also such. I did not find an example where to look for a given word, and not just compare structures. Maybe someone knows how to do this? Or has the necessary information. Thanks in advance for your help
\Device\NUL
Anonymous
Microsoft seems to have deleted gets()
\Device\NUL
gets() only exist because backward compability with executable that using ANSI C
Αλι
Anonymous
guys why the o/p is Amit1231334513,34,5 ? my expected output is only Amit1231334513 can any one help ?
That is because you have not read the documentation of remove_if. If you read it, you would know why your code prints the wrong output.
The return value from remove_if points one past the last value that is valid after all the characters that don't pass the predicate are removed. So you have to print only in that range to see the desired output.
Try this:
auto it = remove_if(s.begin(), s.end(), chk);
for_each(s.begin(), it, [](const auto& c){cout << c;});
Pavel
Anonymous
Kirk
I'm having a problem with deleting every node who has a certain value in a linked list (https://pastebin.com/ursspctD):
after the DeleteByValue function executes i get a segmentation fault exclusively when the first node needs to be deleted. In that case it seems like the function isn't able to change the head value, but i don't understand why.
Anonymous