Want to get first element in array

>want to get first element in array
>array[0]
wtf i hate programming now

Other urls found in this thread:

en.wikipedia.org/wiki/Array_data_structure
ideone.com/GwrvKN
twitter.com/NSFWRedditVideo

yeah, programming is really autistic, I can't believe how anyone can enjoy doing that crap for living, I can understand a hobby, but being a slave and actually have to program shit apps you hate, trully disgusting

>doing a job you don't enjoy 100% of the time is autistic

autist spotted

Wageslave spotted. You will remember this post on your deathbed when you realize you spent your life on ultimately unimportant things you didn't even enjoy.

wtf i hate working now

this

I enjoy programming. Even if the result is something I'm not interested in, the road to it is enjoyable. Been working as a programmer for 8 years. Now what?

>Now what?

nothing, enjoy your life

Use fortran then.

>your code compiles without errors or warnings but doesn't work
>turns out you have to pass &var instead of var as an argument for a function

wtf I hate C now

Quite a contrast to what you wrote before.

array[0] == *(array + 0)
syntactic sugar was a mistake

Retrieve the data from the address defined in the variable array but add an offset of 0 times unit size beforehand.
I see nothing wrong with this, what is your point?

it's just my opinion, you don't have to get triggered by it or live by it

That should not compile cleanly then, it should bitch about you passing a scalar as a pointer. Try using a non-retarded compiler like gcc or clang (they bitch about it all the time when I do it)

It won't compile if the function declaration omits its arguments or if it's declared with varargs (...).

I meant to say comlpain instead of compile.

>posted it again
nice bait

Can you even declare a function without specifying variable types?
You could use a function without declaring it, but then a compiler should warn about implicit function declaration (clang and gcc certainly do).

Okay, varargs in non-standard functions could lead to such a problem. I don't use varargs in my code so I didn't even consider it.

file A:
void f(int a,int b){ ... }

file B:
void f();
main(){
f(10,12);
}

This is valid C, to my knowledge.

>this shit again
wtf i hate Sup Forums now

>want to use a variable i declared earlier
>it's not in scope
fuck this SHIT

> want to get first element in array
array.pop()

Is that better?

You just REMOVED the first element from the array.

get a load of this cuck

Here's a question for you meme lords on Sup Forums:

unsigned char c = 1;
unsigned char d = (c

d = (c

0 points, see me after class

yes ma'am

That's a pretty silly thing to write. What is it that you're trying to achieve here?

>What is it that you're trying to achieve here?
testing Sup Forums's understanding of C

Well of course you would remove an item from an array if you want to get it. It's a basic logic.

Think of it this way: if you want to get a cookie, you have to remove it from a cookie box in order to take it. Same with arrays.

You're not testing any knowledge that matters.

It is not the same with arrays. Get and remove are two different things.

2^8.

Nice excuse, web dev.

Also, if you think arithmetic shifts are not used in practice, you're simply delusional

actually it's 2^9 but im not sure if doesnt fuck up
who uses C anyway

They are used, and the way they are used varies widely based on which compiler and architecture you're using. Asking what the result is without specifying context is pretty stupid.

But that's that overloading the function?

No it isn't, it's 2^8, compile with the int format specifier and see 256.

There's no overloading in C.

As far as I know that prototype has to be either
void f(int a, int b);
or
void f(int, int);
for it to be valid

In C++, yes. In C, you are allowed to omit parameters.

Oh, didn't know this

Well, you still shouldn't do that, though, because it makes it very easy to fuck up.

Here you go OP, I wrote a one-indexed List implementation for you to use in C# because Zero-indexing is super tough and confusing.

public class OneIndexedList : List
{
public new T this[int index]
{
get { return this[index - 1]; }
set { this[index - 1] = value; }
}
}

Hopefully this makes programming that much easier for someone like yourself who struggles to deal with simple concepts.

a-user-kun.... you are wrong...

How do you approach the problem that he still has to read others' code with zero based indexes?

How did you guys even pass intro to programming?

It was too long ago to remember.

but, user...
int a = array[0];

this is valid code and it does not remove the value inside...

Tell him to give up. We don't need programmers like him.

Yeah being poor is entirely better than working for some hours of which you do not enjoy every minute.

A job without assholes does not exist. You meet them everywhere and you won't enjoy working with some of them. That's completely independent from your kind of job.

You must be someone who went to those alternative school where you learn to dance your name.

I think reading other peoples code generally is going to be an impossible task, the zero based index problem there is probably the least of his worries.

string[] nameArr = new string[] { "Tom", "Dick", "Harry" };
string someName = nameArr[1];

someName becomes "Dick" and the array retains all the values. I don't really think you have the first idea what you're talking about.

You are fucking retarded

Jokes on you meathead.
I like programming, I'm paying off a mortgage, I don't have to work in a factory or lift heavy stuff or try to sell stuff or work in retail...

>Read book
>Book disappears

wow wtf I hate reading now

In addition to this - Array's aren't resizable so the only way to "Remove" something from an array is to set it's value to null (if it's a nullable type in this case).

string[] nameArr = new string[] { "Tom", "Dick", "Harry" };
nameArr[1] = null;
string someName = nameArr[1]; // Somename is now null.

If you want behaviour like you're describing in C# you'd have to write your own List implementation which removes the item at the accessed index like so...

public class OneReadOnlyList : List
{
public new T this[int index]
{
get
{
T tmp = this[index];
RemoveAt(index);
return tmp;
}
set { this[index] = value; }
}
}

Quite why you'd ever do that I don't really know.

Tard

>edit someone's script
>it won't run because of inconsistent whitespace characters

wtf I hate Python now

>Array's aren't resizable
No.
They're not in some context, they are in others. There is no authoritative definition that says that arrays are fixed size.

Wrong

>program shit apps you hate
But user, I love the projects I'm working on. If I didn't, I wouldn't be working on it.

implementation defined behaviour.

It somehow didn't return the first element like the OP wanted?

It produced side effects that OP didn't want.

>They're not in some context, they are in others. There is no authoritative definition that says that arrays are fixed size.

But that's wrong.

A resizable array is called a "Dynamic Array".

Arrays have never been resizable because that's not how memory works, higher level languages can do dynamic arrays (with whatever added overhead) because they abstract the memory management entirely.

Go read a book or something.

I did read a book.

If you're writing portable code, you can't make any assumptions about the environment other than what the C standard specifies.

I'm not writing portable code.

Unfortunately reading The Hungry Caterpillar doesn't give you any standing as a programmer.

If your goal is to write portable code, you should stick to one of those web-dev-tier "write once, run everywhere" meme languages.

t. C developer

Did you also remove these words from the internet so you could read my post?

Blame all the people who set tabs to be anything other than 8 spaces in their editors

user, please. Plenty of languages have a built-in data structure named array that can be expanded or shrinked without remaking the object. Any book that claims that arrays are fixed size would effectively be claiming that those languages do not exist, which is just nonsense. There is no authoritative source that says that all arrays are fixed size.

Wrong

>not using smarttab smartindent or whatever the fuck intelligent indenting is called in your language of choice
>not agreeing on code formatting and best practices before starting working on a project together
Found the pajeet

It's undefined then, I always mix those two up.

>If the value of the right operand is negative or is greater than or equal to the width of the promoted left operand, the behavior is undefined.

>If the value of the right operand is negative or is greater than or equal to the width of the promoted left operand
It isn't

Is the array resizable? Then it's a dynamic array.

The fact that some high-level languages choose to make the standard array syntax represent a dynamic array does not suddenly make it a standard array.

Stop arguing if you haven't got the first fucking clue about data structures.

see

>no bounds check

>Accessing an array that's uninitialised

Any initialised array will always have a value at 0, even if that value happens to be null.

Bounds checking is only relavent from index 1 and onwards.

Just because the book you read taught you about the distinction it made between fixed size arrays and dynamic arrays does not mean that all data structures named arrays are forced to be fixed length.

Your word has very little weight for me, so you don't have to repeat your post multiple times. It doesn't help make your point any stronger.

Here's a wiki page about arrays:
en.wikipedia.org/wiki/Array_data_structure

Fixed number of elements is never mentioned.
Before you lose your shit, I'm not giving you this link to demonstrate that all arrays are variable length - I'm trying to demonstrate that there is no authoritative source on whether the data structure called array has to be fixed size or not - each implementation decides for itself what it wants to call arrays.

Did op say that, or are you
> Implying?

>Linking an article that refutes your own argument

Bravo.

Yes, OP said that.

It's still an array.

You sure, pal?
ideone.com/GwrvKN

...

>example uses char
>you use int

You had one job.....

No.

> Yes, OP said that.

>want to get first element in array

Doesn't matter, char is still a numeric type.

Yeah, it doesn't fucking matter, because
unsigned char d = (1

Yes. Particularly, the word "get" is the one that signifies his intent to not cause side effects.

0.
>Widen to int
>1 256 % (1

>get
>gets

Unsigned overflow is defined behaviour in C.

>Any initialised array will always have a value at 0
Not in every language