Jonathan
init a array,set a pointer ,try
Jonathan
that hard
Anno
May be you need read C++ Primer
Anno
Can guys recommand some open repos for beginners(like me)
Guys check this code out please # peer review my code >>> github dot com slash AnonymousM21 slash Mark-Calculator
Anno
actually we can see your repo link from error msg
Yep men check it out if there is any mistakes to modify
Anno
emmmm
emmmm
Admin?
klimi
Anno
I saw error msg before delated
ya?
Nothing
klimi
Nothing
alright o/
Okay please check it out for any mistakes
mj12
Okay please check it out for any mistakes
char b[8]; scanf("%s", b); woups
klimi
What's up?
buffer overflow
mj12
What's up?
What prevents me from entering a string longer than 8 * sizeof(char)
What prevents me from entering a string longer than 8 * sizeof(char)
Check it out it doesn't matter, I tried it
buffer overflow
But you're correct
mj12
are you aware that you can use "%d" as a format string for scanf?
Anonymous
Good day programmers. How do I program a chipset for location
Pablo
Hi guys!!!!
Pablo
does anyone here knows about javascript?
What what?
mj12
Check it out it doesn't matter, I tried it
[meow@Workstation ~]$ ./a.out Enter Mark 1 : 19 Enter Mark 2 : aaaaaaaaaaaaaaaaaa Invalid mark. Enter again between 1-100! Enter Mark 2 : 19 Enter Mark 3 : 101 Invalid mark, > 100. Enter again between 1-100!. Enter Mark 3 : 19 Enter Mark 4 : 1 Enter Mark 5 : 1 __________________ Aggregate : 59 Pecentile : 11.80% *** stack smashing detected ***: terminated Aborted (core dumped)
Apna
/sban
Dima
/blue_text_must_click
klimi
Hi guys!!!!
What drives you to join c/c++ community and immediately ask about javascript?
...mj12 is typing still now?
mj12
Anyway what you can advise me ?
first of all, when you're reading numbers, you don't have to read them as a string, copy them(?), and then pass them into atoi(), you can just pass %d as a format string into scanf also, when you're dealing with strings supplied by the user, on any more or less recent system, you're able to let scanf allocate the memory for you, by specifying either %ms or %as (look it up in the manpage on whatever system you're on)
I used to read them as String because to check if there is a human type error like Enter Mark one : 6o
I used to read them as String because to check if there is a human type error like Enter Mark one : 6o
I mean the person tried to enter number "60" but he typed "six and letter o"
Pavel
github.com/AnonymousM21/Mark-Calculator
What's the point of this line? toInt = atoi(c) * 0;
Pavel
github.com/AnonymousM21/Mark-Calculator
If one symbol is digit you convert the whole line? What if the next symbol is not digit? if(isdigit(c[j]) != 0) toInt = atoi(c); Your oneliner ifs is difficult to read, would be better if you add curly braces and put the part inside the if block on the new line
Pavel
github.com/AnonymousM21/Mark-Calculator
Here you calculate the length of the string every iteration, I don't see c changing inside of the loop, so you could have saved the length outside for(unsigned int j = 0; j < strlen(c); j++) {
mj12
Your aaaaaaaaa.. string probably overrides special safety signature bytes on the stack. Which is good, it detected a buffer overflow in your app
I am perfectly aware, i was just demonstrating that him saying "it doesn't matter" is wrong, since the application still crashes
ㅤㅤㅤㅤㅤ
A two-dimensional series is given. Find the maximum number of elements in this series. Input: n=3 1 2 3 4 5 6 7 8 9 Output: 8
Dima
read the rules, no assignment requests
Dima
try to solve it by yourself first
ㅤㅤㅤㅤㅤ
how do i work around this issue in c
ㅤㅤㅤㅤㅤ
try to solve it by yourself first
I tried it, but it didn't work
ㅤㅤㅤㅤㅤ
Pavel
I tried it, but it didn't work
Can you show your code?
ㅤㅤㅤㅤㅤ
yea
ㅤㅤㅤㅤㅤ
#include<stdio.h> #include<stdlib.h> #include<time.h> int main() { srand(time(NULL)); int a[100][100],n; printf("n: ");scanf("%d",&n); for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { a[i][j]=rand()%10+100; printf("%2d ",a[i][j]); } puts(""); } puts(""); int max=a[0][0],count=0; for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { if(a[i][j]>max) { count++; max=a[i][j]; } } } printf("%d \n",max); printf("%d ",count); }
ㅤㅤㅤㅤㅤ
I don't know where to put count++
Nomid Íkorni-Sciurus
guys how do I make a socket blocking mode? my recvfrom is always setting errno 11 and I really just want to wait for the response I don't need async mode
Nomid Íkorni-Sciurus
int sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP); then I set timeout then: fcntl(sock, F_SETFL, flags ^ O_NONBLOCK); to make it blocking - but doesn't work
You know me
Put listen*
Nomid Íkorni-Sciurus
the example doesn't use listen
Nomid Íkorni-Sciurus
it's not async
You know me
Listen has nothing to do with async. It is used to listen on the port and then we accept the incoming connection. In your case it looks like you are doing something other than accepting connection.
You know me
Icmp is the protocol used by ping
You know me
What exactly are you trying to do ?
Nomid Íkorni-Sciurus
I'm trying to send a ICMP_ECHO
You know me
Ohk
Nomid Íkorni-Sciurus
and then getting the response
Nomid Íkorni-Sciurus
sendto works, but recvfrom doesn't
Nomid Íkorni-Sciurus
the errno set by recvfrom is always 11, which suggests me the socket is not in blocking mode
Nomid Íkorni-Sciurus
I tried to set it with fcntl but it doesn't work
Nomid Íkorni-Sciurus
Okay, the problem was the timeout I put 1ms of timeout instead of 1s
You know me
Maybe you are setting the weong option. pls check if SO_RCVTIMEO is required
Nomid Íkorni-Sciurus
Maybe you are setting the weong option. pls check if SO_RCVTIMEO is required
yeah it was the timeout... but I still get errno 11 from recvfrom
Nomid Íkorni-Sciurus
I tried with 2 seconds and still won't receive
Nomid Íkorni-Sciurus
maybe the packet I'm sending is malformed...
What's the point of this line? toInt = atoi(c) * 0;
If every single characters are not digits to make their value to zero for the next if else check if(toInt != 0) break; else { printf("Invalid mark. Enter again between 1-100!\n"); continue; }