Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

I AM NOT GOOD AT PROGRAM

Name: Anonymous 2009-10-31 17:31


#include <iostream>

int *modi (int *array)
{
    int *start = array;
   
    for (int x = 0; x < 10; x++)
    {
        array[x] = x;
    }
   
    return start;
}
   

int main ()
{
    int arr[10] = { 0 };
   
    for (int x = 0; x < 10; x++)
    {
        std::cout << arr[x];
    }
   
    modi (arr);
   
    for (int x = 0; x < 10; x++)
    {
        std::cout << arr[x];
    }
   
    std::cout << "niggers";
   
    return 0;
}


So I just wrote this. I know what it does, and I know that it works, but I don't know how it works.
int *start dereferences, but the value is undefined, and oh god how the fuck did I make this compile.
Please help.

Name: Anonymous 2009-10-31 17:42

Name: Anonymous 2009-10-31 17:45

>>2

Good sir, your post seems to have ran away. Would you like me to help you find it?

Name: Anonymous 2009-10-31 17:47

Name: Anonymous 2009-10-31 18:32

>>4
Please refrain from posting non-programming related material.

Thank you.

Name: Anonymous 2009-10-31 19:15

>>5
Please refrain from posting programming related material.

Thank you.

Name: Anonymous 2009-10-31 19:44

>>1
you don't need to copy array to start.
Just return array after you've done the mod function.

Name: Anonymous 2009-10-31 20:17

>>7
It's not being copied, not the whole array

Name: Anonymous 2009-10-31 20:20

>>1,2,3,4,5,6,7,8
YHBT

or at least I hope to god you have been

Name: Anonymous 2009-10-31 21:12

>>9
UNOPTIMIZED QUOTES!

Name: Anonymous 2009-10-31 21:18

>>10

Typical python programmer.

Name: Anonymous 2009-10-31 21:26

>>1
I know what it does
I'm pretty sure you don't.

int *start dereferences
No, it doesn't. It declares start as a pointer to integer, with the same value as array itself. If you wanted to dereference anything, you should have written:


int start = *array;


Additionally, the first element of arr is in fact defined as you initialized arr with { 0 }; .

Name: Anonymous 2009-10-31 22:54

>>12

Nigger, I know that I am returning a pointer to an array, I just didn't understand the syntax. Do you honestly think that I could use a piece of code without understanding what it was doing?

Name: Anonymous 2009-10-31 22:57

>>13
*American of African descent

Name: Anonymous 2009-10-31 23:12

Do you honestly think that I could use a piece of code without understanding what it was doing?
Is this a serious question? OF COURSE YOU FUCKING COULD

Name: Anonymous 2009-10-31 23:12

>>12

This (>>13) is what you get for helping him.

Name: Anonymous 2009-11-01 4:13

>>13
i dont know why i just did this but it might help you.

int shit[10];

int *dong = &shit;
int *dick = shit;

if(dong == dick)
puts("ARRAYS SUCK");

Name: Anonymous 2009-11-01 11:03

>>14
Implying I'm American

Name: Anonymous 2009-11-01 11:36

>>13
Do you honestly think that I could use a piece of code without understanding what it was doing?
But you just did.

Also I don't understand your problem at all.

Name: Anonymous 2009-11-01 12:34

>>13
Do you honestly think that I could use a piece of code without understanding what it was doing?

Um, this is kindof the point of encapsulation and loose coupling. Better hope you never work on a team of size greater than one...

Name: Anonymous 2009-11-01 13:20

While I do approve of your indentation style(very pleasing to the eyes), I believe you may have too many newlines in your code. By reducing the amount of lines with nothing on them, your code becomes much more readable.

Name: Anonymous 2009-11-01 13:24

This is why we don't program in sepples.

Name: Anonymous 2009-11-01 13:27

>>21
au contraire, if you double line space you code it becomes twice as readable

Name: Anonymous 2009-11-01 13:38

[code]
// how to conjure the spirits of the computer

#include <iostream> // this includes the iostream spell book,
                    // allowing us to cast io related spells

int main() {
  cout << "Hello, world" << endl;  // here we use our magic powers
                                   // to channel the string to the
                                   // cout object.
  return 0;
}

Name: Anonymous 2009-11-01 13:39


// how to conjure the spirits of the computer

#include <iostream> // this includes the iostream spell book,
                    // allowing us to cast io related spells

int main() {
  cout << "Hello, world" << endl;  // here we use our magic powers
                                   // to channel the string to the
                                   // cout object.
  return 0;
}

oops

Name: Anonymous 2009-11-01 13:52

>>20
That's not the point of encapsulation, actually encapsulation is of little importance most of the time.

People write functions and/or methods which combine some operators in such a way that it now performs some more complex functionality and give that functionality a name. That's called abstraction.
You don't want "encapsulation", you want publicly exported APIs which you can use (and hopefully, with proper documentation).

Name: Anonymous 2009-11-01 14:26

ENCAPSULATE MY ANUS

Name: Anonymous 2009-11-01 14:50

>>26
Should be pretty obvious by this point that YHBT, though I must admit, I would be tempted to take the bait too.

Name: Anonymous 2009-11-01 15:02

Fixed OP's code.

#include <stdio.h>

int* modi(int *array)
{
    int *start = array;
    for (int i = 0; i < 10; ++i)
        array[i] = i;
    return start;
}

int main()
{
    int arr[10] = { 0 };
    for (int i = 0; i < 10; ++i)
        printf("%d", arr[i]);

    modi(arr);
    for (int i = 0; i < 10; ++i)
        printf("%d", arr[i]);

    printf("people of African descent");
    return 0;
}

Name: Anonymous 2009-11-01 15:08

>>29
printf("people of America-african descent");
Fixed your code.

Name: Anonymous 2009-11-01 15:29

  public boolean rescheduleJob (SchedulerJob job) throws ValidityException, ParsingException, IOException {
        String rescheduleXml = job.getRescheduleXml();
        if (rescheduleXml.length() == 0) {
            return false;
        } else {
            Builder parser = new Builder();
            Document doc = parser.build(rescheduleXml, "");
            BaseIterator baseIter = new BaseIterator(TimeZone.getTimeZone(job.getTimeZone()));
            baseIter.setDayPattern (getStr(doc,"Date/@Start", ""), getStr (doc,"Date/@End", ""),
                    getInt(doc,"Date/@Intv", 0), getInt (doc,"Date/@IntvType", 5));
            baseIter.setTimePattern (getStr(doc,"Time/@Start", ""), getStr (doc,"Time/@End", ""),
                    getInt(doc,"Time/@Intv", 0), getInt (doc,"Time/@IntvType", 11));
            baseIter.setExclusions (getInt (doc,"Exclusions/@Weekly", 0xFF),
                    getInt (doc,"Exclusions/@Monthly", -1));
            Date newWakeUp = baseIter.next(job.getWakeUp());
            if (newWakeUp != null) {
                job.setWakeUp (newWakeUp);
                return true;
            } else {
                return false;
            }
        }
    }

Don't change these.
Name: Email:
Entire Thread Thread List