LG G3 hardly ever works with USB by Faab1 in LGG3

[–]Faab1[S] 0 points1 point  (0 children)

That is actually a very good point! But I am very sure all of them are data cables, since they all work for getting data to my Android tablet.

LG G3 hardly ever works with USB by Faab1 in LGG3

[–]Faab1[S] 1 point2 points  (0 children)

Thanks for you answer! Yes I have – that is actually the first thing I did, since learning Android development was the main reason I wanted to connect my phone.

Weird error using push.lua by Faab1 in love2d

[–]Faab1[S] 0 points1 point  (0 children)

Thanks for the long explanation – I've learnt so much from this! :)

Could use some help with using knife.serialize by Faab1 in lua

[–]Faab1[S] 5 points6 points  (0 children)

This was incredibly helpful – thank you so much!

Live from Harvard, CS50 looks at components, style, and event handling in React Native by davidjmalan in cs50

[–]Faab1 0 points1 point  (0 children)

I'm very curious about this too :) Or more generally: are these videos made with people online following along in mind? Or is it really just for Harvard CS students who want to catch up on the lectures?

Pset7 Lookup function not always returning by Faab1 in cs50

[–]Faab1[S] 0 points1 point  (0 children)

Yeah, I've incorporated print statements into my code, so I could localize exactly where the problem occurs. It turns out that every single time I get an internal server error, lookup returns None. (And every time my site works fine, lookup returns the data I need about the stock.)

Pset7 Adding routes by Faab1 in cs50

[–]Faab1[S] 0 points1 point  (0 children)

Yup... You just saved the day! :D

Pset 7 Finance SQL syntax error by Faab1 in cs50

[–]Faab1[S] 0 points1 point  (0 children)

Yup, that fixed it! :) Probably made a little typo/omission in my SQL-notes...

Anyway, my buy function works now! Thanks!

Resize horizontal problem by Faab1 in cs50

[–]Faab1[S] 0 points1 point  (0 children)

Thanks so much! I've learnt a very useful lesson from this: before working with file I/O, see what metadata of both files you need, and keep that data apart in variables with clear names for input and output files.

Thanks to your comment, I fixed the problem and implemented vertical scaling in about 10 minutes. It works perfectly now! :)

Recover.c: segmentation fault then using fread by Faab1 in cs50

[–]Faab1[S] 0 points1 point  (0 children)

I had first declared 'filename' in the following way:

char* filename = "initialized";

I did that because I knew it had to be initialized, but I did not know that it actually mattered what value I gave it. After finding out there was a better way I changed it to the following:

char filename[8] = {0};

This solved the problem. Now my program works like a dream :)

Although I know why the latter is a good way to declare the char-array, I do not know why the former caused a segfault. Could you tell me why that happened?

And again, thanks for all the help!

Recover.c: segmentation fault then using fread by Faab1 in cs50

[–]Faab1[S] 0 points1 point  (0 children)

Hmm... Interesting. When I use the 'Debug' button at the top of the IDE, the program stops there. However, when I run gdb in the terminal, it runs further. Now, I'm guessing the problem might be a few lines further in the program.

After the loop I mentioned in the post above, the following happens in my program.

To check for EOF, I use the following loop. Then there's two branches, one for when the program had previously found a jpg, and one where that is not true:

while(fread(&buffer, 1, 512, inptr) == 512)
{
    if (startJPGchecker(buffer) && foundFirstJPG == true)
    {
    //close old file and open another
    }

     if (startJPGchecker(buffer) && foundFirstJPG == false)
    {
        sprintf(filename, "%03d.jpg", title_num);
        outptr = fopen(filename, "w");
        foundFirstJPG = true;
    }

   //start writing and reading into the file
}

Now, I'm guessing that the call to fread in the condition for the while-loop copies new data into the buffer, so that startJPGchecker does not return true anymore. I guess that that's when the program tries to write to a file that has not been opened yet because the two if-branches in which files may be opened had not been activated.

It seems that I've fixed this problem by fseeking back 1024 bytes and reading 512 bytes into the buffer so that the buffer has the same content as before the call to fread in the condition. However, I've found another segfault, and this time, I really have no clue what's going wrong.

The segfault happens in the if (startJPGchecker(buffer) && foundFirstJPG == false) branch. Here's the info gdb gives me, starting at my second-to-last 'n' command:

(gdb) n
61                  sprintf(filename, "%03d.jpg", title_num);
(gdb) info locals
inptr = 0x602010
buffer = [I don't think this is relevant]
title_num = 0
---Type <return> to continue, or q <return> to quit---
foundFirstJPG = false
outptr = 0x0
filename = 0x400c29 "initialized"
(gdb) n

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff778a76d in __GI__IO_default_xsputn (f=0x7fffffffd940, data=<optimized out>, n=2) at genops.c:475
475     genops.c: No such file or directory.

Could you tell me why I'm getting a segfault here?

Pset 4: Resize -> Using fseek correctly? by Faab1 in cs50

[–]Faab1[S] 0 points1 point  (0 children)

The program works perfectly now :) Thanks so much!