coal
also what i love about C is that there's also embedded languages like Lua, so you can use them to interface with your robot which is amazing
coal
Ohh thats right but am not good enough in c++
are you better in assembly than in C
coal
what kind of asm
4hk
hey, I want to use the class "Student" inside class "Class", but it wont let me this way: https://pastebin.com/iAAnqLQC , pero cuando pongo la clase "Estudiante" primero que la clase "Clase", no pasa este error, debería ser así?
Anonymous
Am having better understanding with low level language moving towards the high level ones "bottom up approach
coal
there's other way to do that, you can make a namespace and declare your class within it
coal
then you can access your class like "Estudiante::Clase", "Estudiante" being the namespace
coal
oh wait i actually misread your question
4hk
my english is gone, ty
coal
lo que pasa es que you're trying to look for a class which is not declared "yet"
\Device\NUL
Remember guys, Only english language is allowed
coal
remember that the code is read from top to bottom
coal
Remember guys, Only english language is allowed
yes, but we're not establishing a complete conversation in spanish so its fine
coal
remember that the code is read from top to bottom
when the compiler arrives at your "Class" class, it realizes you're trying to use a "Estudiante" class which is not declared yet the compiler doesnt know you're gonna declare it later so it breaks
4hk
I didd it, thank you :)
Anonymous
#include<stdio.h> #include<stdlib.h> #include<strings.h> int main() { char name[128]; printf("Type your name: "); scanf("%s",& name); if(strcmp(name,"Bob\0")==0 || strcmp(name,"Alice\0")==0 printf("Best wishes and greetings %s\n", name); return 0; }
Anonymous
is this correct?
klimi
is this correct?
test.c: In function ‘main’: test.c:10:8: warning: implicit declaration of function ‘strcmp’ [-Wimplicit-function-declaration] 10 | if(strcmp(name,"Bob\0")==0 || strcmp(name,"Alice\0")==0 | ^~~~~~ test.c:4:1: note: include ‘<string.h>’ or provide a declaration of ‘strcmp’ 3 | #include<strings.h> +++ |+#include <string.h> 4 | test.c:10:60: error: expected ‘)’ before ‘printf’ 10 | if(strcmp(name,"Bob\0")==0 || strcmp(name,"Alice\0")==0 | ~ ^ | ) 11 | printf("Best wishes and greetings %s\n", name); | ~~~~~~ test.c:13:1: error: expected expression before ‘}’ token 13 | } | ^
Anonymous
is it correct then?
\Device\NUL
is it correct then?
Why you type \0 in the string "str" is equal to 's' 't' 'r' '\0'
Anonymous
please correct it
coal
is it correct then?
it has a syntax error, and "strings.h" is probably "string.h"
coal
please correct it
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char name[128]; printf("Type your name: "); scanf("%s",& name); if(strcmp(name,"Bob\0")==0 || strcmp(name,"Alice\0")==0) printf("Best wishes and greetings %s\n", name); return 0; }
Anonymous
oh than you
coal
yw
Anonymous
you're right
coal
yay
klimi
i feel like this was just some sort of homework...
Alex
Hello there! Could someone help me in solving my problem, it lies in the fact that I cannot display two words, the last letter of which is the same. I found this case, and I display the letter that matches, but I don’t know how to display these two words.
coal
i feel like this was just some sort of homework...
yeah but ill help if they at least demonstrate an attempt to solve their problem
Prince Fine
hey guys how can i count the occurence of a letter in a given word ?
Golden Age Of
hey guys how can i count the occurence of a letter in a given word ?
std::count(str.begin(),str.end(),'s');
Prince Fine
std::count(str.begin(),str.end(),'s');
first of all i'm still on using namespace std; so i don't use std::cout or any thing
Anonymous
Hi
Anonymous
What is the uses of "extern c;" in a code
Anonymous
And in which function we will run it
Prince Fine
What is the uses of "extern c;" in a code
i think it's used to extend the visiblity of the variable
Prince Fine
Anonymous
So , why we used "func()" in our code lol?
Golden Age Of
What is the uses of "extern c;" in a code
Extern says compiler that your variable is already declared somewhere else, and u don't want to create another one, u say to compiler :"Please, find that, I already have it"
Golden Age Of
What's the main definition of itM ?
For example you have a big global object in some file(not the most common example, butc just imagine) and you need this one in another file But, to create this object, imagine, we need 3 seconds. So, we don't want to create one more such object and waste 6 seconds except of 3 one time So, there it goes. In the file we want to use this big object we say to compiler extern BIG_OBJECT; This way compiler won't create one more object for your file, it will try to find it somewhere.
Golden Age Of
If I'm missed, experts, please, let me know and say what's wrong
Anonymous
If I'm missed, experts, please, let me know and say what's wrong
He asked about "extern C" which is a language linkage directive. You explained about external linkage. extern "C" does a lot of additional things like for example turning off name mangling amongst other things.
coal
apart from disabling name mangling
coal
what does it do
Anonymous
Yes?
coal
Yes?
yes
Anonymous
apart from disabling name mangling
The language linkage directive could also control calling conventions.
labyrinth
I found some headers would, under a certain namespace, declare a class like class Foo; which is defined and implemented in a separate .h and .cc file; what is the purpose of this line?
Pavel
I found some headers would, under a certain namespace, declare a class like class Foo; which is defined and implemented in a separate .h and .cc file; what is the purpose of this line?
You probably talking about forward declaration https://www.google.com/amp/s/www.geeksforgeeks.org/what-are-forward-declarations-in-c/amp/
pyMorgado
hi, why the message "the project does not know how to run the profile" of my application?... in visual studio, when running the debugger
Talula
hi, why the message "the project does not know how to run the profile" of my application?... in visual studio, when running the debugger
You have not selected the right project to execute when you click run... On the right side, right click on the project you want to run and click "set as Startup Project".
Compiler🇮🇷
Hi
Compiler🇮🇷
What pinned message?
klimi
What pinned message?
https://t.me/programminginc/283193
Hsn
is there somthing wrong here that im missing ? ==== module_b.c ==== static char buffer[200]; char * pGetModuleBuffer(){ return buffer; } ==== module_a.c ==== function_a(){ char *pWriteBuffer = pGetModuleBuffer(); snprintf(pWriteBuffer, 200, "text stuff %d", 123); }
klimi
and you include module b in module a?
Hsn
well im getting "implicit declaration" but that doesnt matter.
Hsn
linker is smart enough to find the fucntion
Hsn
meaning yeah .. i didnt do prototype of the function in module_b.h
Pulkit
Can anyone recommend me how to begin c++ like resources to learn and practice?
Pulkit
I'm a beginner
klimi
linker is smart enough to find the fucntion
i don't think that is the... clever way...
klimi
i mean i get that you are creating static hcar buffer... but it seems a bit wrong...
Pulkit
YouTube
Can you be a little more specific it's filled with many bad mentors too especially after the removal of dislike button
Hsn
i don't think that is the... clever way...
i know im debugging now, not final code.