Liam
Do you really know how to define a variable in C++?
Liam
here, line 1, declaration of int foo.
Anonymous
Liam
here, line 5, usage of undefined variable foo.
Anonymous
my.h has that
Liam
here, line 7, usage of undefined variable foo.
Anonymous
You need declared variable foo
Liam
but no definition.
Anonymous
and create function print_foo(0
Liam
$ cat linkee.h #include <iostream> extern int bar; void print(int i); void print_bar(); $ cat linkee.cc #include "linkee.h" int bar = 0; void print(int i) { std::cout << i << std::endl; } void print_bar() { std::cout << bar << std::endl; } $ cat linker.cc #include "linkee.h" int main() { bar = 24; print_bar(); print(42); return 0; } $ g++ linker.cc linkee.cc $ ./a.out 24 42
Anonymous
my.h has that
You declared foo is global varibale
Anonymous
Guys i need small help
Anonymous
I print # now many time loop go inside want increase # size??
Anonymous
How to perform this
Anonymous
Help me
Liam
my.h has that
extern int foo declares foo, but does not define it. have you got this now?
Anonymous
I need help
Liam
extern int i; // declaration, not definition int i; // declaration and definition, but not initialized int i = 0; // declaration and definition, initialized with 0 @sid_artix
Liam
yeah i get it now
glad to know
Anonymous
@sid_artix
Anonymous
I need some help
Anonymous
does this mean i should define the value of foo in my.cpp as well?
Anonymous
Anonymous
I want increase size of # so how to increase size
Anonymous
When loop go inside first #..then 2 times in loop ##
olli
does this mean i should define the value of foo in my.cpp as well?
yes, your source file should define foo as well
Anonymous
5 times in loop #####
Anonymous
When loop go inside first #..then 2 times in loop ##
so you want to print # twice? == 2 times loop?
Anonymous
I want to print many time # when loop go inside
Anonymous
for(int i = 0 ; i < 5 ; i++){ cout << "#"; }
Anonymous
In c
Anonymous
idk C -.—
Anonymous
Ok
Anonymous
I want to learn c++
Liam
printf("#")
Anonymous
Source of learning c++
Anonymous
printf("#")
No bro that's like small game so i can't do that
Nils
printf("#")
I have seen people doing printf("%c", '#');
Nils
No bro that's like small game so i can't do that
In ASCII style? Or just a normal graphical game? In 3D?
Anonymous
which language has a better scope. c++,c or python
Nils
Just normal snake game
Ok, that's even possible without (n)curses
Anonymous
versatility
Liam
Just normal snake game
learning both of them makes your scope larger.
Anonymous
My 95% work done...bow only size increases step
Anonymous
and c
Anonymous
which is more machine friendly
Nils
How to do
Well you need a drawing function and a movement function. The movement function defines the beginning and the end position of the snake while the drawing function draws it to the terminal.
Nils
Oh and of course the control function which can modify the behavior of the movement function.
Anonymous
Any trainer for c 11
Nils
Any trainer for c 11
What do you mean by "trainer"? A human who gives direction or a tutorial with tasks (like hackerrank)
PO
someone knows how can I get last 3 char of string in c programming?
PO
"Get"? From stdin?
User will type <file_format> and <file_name> on commande line
PO
I have done every thing with argv
PO
but I don't know how to get last 3 char to compare with <file_format>
Nils
User will type <file_format> and <file_name> on commande line
file_format would be argv[1] and file_name would be argv[2] ig
Nils
But from where you want to "get"? Do you want to check if the file name ends with the file format given?
PO
For example: /.Myprog -f <file_format> <file_name> /.Myprog -f pgm hello.pgm
Anonymous
like just look at cppreference
Nils
I have to compare pgm of format and with pgm of file_name
Ahhh, so you want to cut the .pgm off hello.pgm so you get just hello?
Nils
Find the position of the .pgm and set a null-terminator
Anonymous
like just look at cppreference
https://en.cppreference.com/w/cpp/string/byte heck i just found strrchr() that's a better match for what you want to do