[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip / qa] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/wsr/ - Worksafe Requests


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: Untitled.png (25 KB, 607x615)
25 KB
25 KB PNG
>>
I managed to hack my way through a few other errors since I last posted, but with this one I wouldn't even know where to start. I certainly hope the next tutorial I find will be more focused on what can go wrong.
>>
Specify the sizes of name and clas between [ ]
>>
>>1488920

In C arrays in size HAVE to be knows at compile time, an empty [] is not allowed.
Depending on the compiler you CAN pass a varaible to an array (Varaible Length Array), but it cannot be empty. Use a define statement, e.g.

#define MAX_LEN_NAME 21
#define MAX_LEN_CLASS 41

(...)
char name[MAX_LEN_NAME];
cahr clas[MAX_LEN_CLASS];
(...)
>>
char *name;

welcome to C
>>
>>1488930
>>1488934
The tutorial dude had it empty. I've used a bunch of empty [] myself in previous exercises. But it doesn't matter, I added the size and it worked and I'm going to keep doing it like that I guess.
>>1488938
This gave me an error so yeah. What is * supposed to do?
>>
>>1488930
>>1488934

I forgot the thank yous, so thank you.
>>
>>1488945
* is just a pointer (which means that it's not "actually" storing the data, it's just pointing to the data. instead of storing 1000 characters in the struct, you would be storing 1 memory address)

when it comes to char, [] and * effectively achieve the same thing by turning the single char into a sequence of chars (otherwise known as a string) because the char* will point to the beginning of the string
>>
>>1488948
Ok, thanks. I'll try to use it again when I'm more advanced.
>>
>>1488953
Pointers are fundamental bro
>>
>>1488973
https://www.youtube.com/watch?v=KJgsSFOSQv0

The part I was stuck on here is structs. You might notice pointers are later in the video, onii-chan.
>>
>>1488979
Pointers are fundamental and you need to know this concept as a beginner.
>>
>>1488984
relax dude, he's going step by step. you dont start off with pointers if youre completely new to programming
>>
>>1488985
born in a post python world
it is a luxury that you're able to say this
>>
>>1488920
I suspect you don't know programming yet.
I suggest you do Harvard's CS50 course, it's for beginners. It actually teaches you programming using C (and other languages later on), like how you're supposed to think about the problem.



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.