Anonymous
so
Anonymous
that's right
Pavel
for ( i = 0; i >= N; i--){
No, forget about my comment, I didn't notice you loop is reversed
@unchanted
#include <iostream> int main() { int N; Int max=0; std::cin >> N; if ( N >= 3 ){ for ( i = N; i >= 0; i--){ If(max<i){max=i;} } } Cout<<max; }
@unchanted
Like this
@unchanted
It was just to print the maximum number isn't it?
Anonymous
#include <iostream> int main() { int N; Int max=0; std::cin >> N; if ( N >= 3 ){ for ( i = N; i >= 0; i--){ If(max<i){max=i;} } } Cout<<max; }
#include <iostream> int main() { int N; int max = 0; std::cin >> N; if ( N >= 3 ){ for ( i = N; i >= 0; i--){ If( max < i ){ max=i; } } } std::cout<<max; }
Anonymous
#include <iostream> int main() { int N; Int max=0; std::cin >> N; if ( N >= 3 ){ for ( i = N; i >= 0; i--){ If(max<i){max=i;} } } Cout<<max; }
 clang++-7 -pthread -std=c++17 -o main main.cpp main.cpp:9:10: error: use of undeclared identifier 'i' for ( i = N; i >= 0; i--){ ^ main.cpp:9:17: error: use of undeclared identifier 'i' for ( i = N; i >= 0; i--){ ^ main.cpp:9:25: error: use of undeclared identifier 'i' for ( i = N; i >= 0; i--){ ^ main.cpp:11:12: error: use of undeclared identifier 'i' If( max < i ){ ^ 4 errors generated. compiler exit status 1 
Artöm
Variable i is not declared anywhere
Anonymous
i must declared i after std::cin » N;?
Anonymous
?
Anonymous
Variable i is not declared anywhere
G B, [14.07.20 18:46] i must declared i after std::cin » N;?
Artöm
It can be declared anywhere, but its better to do it right before usage in smallest scope possible
Dima
#googleit
Loner〽💻
in this code:: int filelength; PBYTE pBuffer; HANDLE hFile; filelength=GetFileSize(hFile,NULL) pBuffer=malloc (filelength+2); Am getting an error from the last line👇👇 invalid conversion from 'void' to PBYTE {a.k.a unsigned char*} What might be the problem??(am using c)
Dima
pBuffer = (PBYTE) malloc()
Artöm
You are copiling as C++
Artöm
Use gcc not g++
@unchanted
Use visual studio instead of visual studio code
@unchanted
I also faced the same problem
Loner〽💻
You are copiling as C++
initially,and they both gave the same arror
Artöm
You gave the exact message? 'void', not 'void*' ?
@unchanted
When to call an object with pointer and when to call with reference?
@unchanted
Why are there 2 separate ways?
Loner〽💻
pBuffer = (PBYTE) malloc()
I think this might work.thanks
Pavel
If you meant that, then I didn't get it :)
piggyho
pBuffer = (PBYTE) malloc()
void* malloc( std::size_t size ); https://en.cppreference.com/w/cpp/memory/c/malloc given the above, what do you need to do?
Bojan_Krdemn
Hi! is it legitimate to declare switch as : switch(direct){ case NORTH: case SOUTHEAST: where dir is of type int
Alex
hi.yes
Alex
however its not the best approach
Anonymous
You can call only functions
@unchanted
Call by reference and call by pointer?
Anonymous
You Can't Call An Object
@unchanted
What is the difference between pass by reference and pass by pointer?
@unchanted
If in one case i use pass by reference and in another i use pass by pointer then how both cases are going to effect my code
#define CLEAR_BUFFER while ( getchar ( ) != ’ \n ’ )
hello here !
#define CLEAR_BUFFER while ( getchar ( ) != ’ \n ’ )
Please, need a software name that can do stuff like that
Dima
Bruh.
piggyho
When to call an object with pointer and when to call with reference?
internally a ref is actually a pointer. the implementation is hidden refs can be easier to deal with.
piggyho
If in one case i use pass by reference and in another i use pass by pointer then how both cases are going to effect my code
the end result is that you are not making a copy of the object. ref internally are actually pointers, the compiler handles the pointer stuff if you pass by pointer, additional checks that it is not nullptr are a good idea.
#define CLEAR_BUFFER while ( getchar ( ) != ’ \n ’ )
Tensorflow maybe
Not programming! I want to draw and put it inside a powerpoint for example.
01000001011011010100000101101110
Not programming! I want to draw and put it inside a powerpoint for example.
Search for Tensorflow playground And try not having offtopic discussions here.
Bojan_Krdemn
however its not the best approach
how to make better? I need to switch between directions and iterate over directions
Bojan_Krdemn
without making a new enum class
#define CLEAR_BUFFER while ( getchar ( ) != ’ \n ’ )
Ok ! Thanks !
Alex
without making a new enum class
but you already have enum for SOUTHEAST, NORTH
Bojan_Krdemn
yes, without making a class named direction and defining a ++ operator Direction operator ++(Direction& dir, int);
Alex
just name enum where you defined NORTH, and you this enum instead of int
Bojan_Krdemn
then i won't be able to iterate over enum values
Bojan_Krdemn
``for (int dir=NORTH; dir!=EASTEAST; dir++)`
Alex
``for (int dir=NORTH; dir!=EASTEAST; dir++)`
https://stackoverflow.com/questions/15451382/implementation-of-operators-for-enum-class
数学の恋人
can someone recommend me an approach for following problem? I have a large file in format ... ... THE 2487241232 HAT 123891231 ... ... Basically a three lettered word and then a number next to it after one space I want to add all those numbers.
klimi
Yeah loop through it?
klimi
Discard first and add second to the counter
数学の恋人
ah right
数学の恋人
Just STD::cin 2 variablrs
but that takes input from stdin right?
klimi
but that takes input from stdin right?
Oh from a filestream or how they call it
数学の恋人
I know that
klimi
You can somehow read a file with it too I am sure
数学の恋人
yes I can
klimi
Also I usually use pipes in linux
数学の恋人
but then I'll have to get it as string
数学の恋人
Also I usually use pipes in linux
lol same, it's far easier In my case it'll be like cat file.txt | cut -d' ' -f2 | paste -sd+ | bc
klimi
Yeah lol
klimi
Or maybe not... What does paste do? I havent seen that