Why this code has an error? (Code below) Please help!! 🥺 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why this code has an error? (Code below) Please help!! 🥺

#include <stdio.h> int main() { int a[] = {1,2,3,4}; int *b = a[1:2]; printf("%d", sizeof(b)); return 0; } I am not getting that why this code has an error?

13th Jan 2021, 7:37 PM
Mahima Rajvir Singh
Mahima Rajvir Singh - avatar
3 Answers
+ 2
Maybe it is because [1:2]? I haven't seen anything like that in c but python do have it as list slicing .
13th Jan 2021, 7:41 PM
Abhay
Abhay - avatar
+ 1
Abhay Thank You! 😊
14th Jan 2021, 3:53 AM
Mahima Rajvir Singh
Mahima Rajvir Singh - avatar
+ 1
Mirielle Thanks a lot! 😊
14th Jan 2021, 3:53 AM
Mahima Rajvir Singh
Mahima Rajvir Singh - avatar