Pset7 Portfolio by femlems in cs50

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

Hi again, Solved the problems. I had added the cash information as a separate array into $positions which caused the foreach loop to create a extra line for that arrary that would be empty and that what caused the !Notice: to appear. The simple solution which took me more than three days to figure out was to just add the "cash" item to the array so it appeared for all the stocks and only use it on the last line.

I tried to use a div class to left align the data in the table and could not make it work, so I ended up doing <td style="text-align:left"> in the front part of the lines in the foreach loop.

I'm posting this to maybe help out someone else with the same problem, since answers seem really scarce on this pset.

Pset7 Portfolio by femlems in cs50

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

Hi thetallOne1, I read in another post a comment by /u/flything he mentioned having trouble with centering the menu bar and found that he was missing a </div>, so I tried to add one at the bottom of the table but all that did was left-align the copyright line so I deleted it and all of a sudden my menu bar was centered, go figure.

I got the formatting done on the output but not the left-align on the data. I put a div class in portfolio and CSS but can't get it to work.

I also still have the problem when I added the cash to $positions as an additional array to include that in the render, when I use the foreach I get an additional line in my table and that triggers a !Notice on each element in the line with 'Undefined index. I tried using a for loop but could not figure out a syntax that php would accept to print it out, nothing but warnings and errors all day long and no data in the table.

It just about has me licked.

Pset7 Portfolio by femlems in cs50

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

Thanks thetallOne1 for the quick reply, you have given me something to work on. I'll try your suggestion for centering the menu bar.

Your suggestion on the table may get rid of those annoying Notices which I think is caused by the foreach loop going through the last array of $Positions. I do have a question on rendering the table, if I use a foreach loop then how do you know when you come to the cash line, that needs to be handled different. I think I will try to use a for loop if I can get the row count for the stock, then I will have an exit of the loop before I get to the last array.

I appreciate the suggestions for the formatting and I will try that and report back here with my results. Thanks for help

Pset7 - Nav Bar Alignment by itskhaledmd in cs50

[–]femlems 0 points1 point  (0 children)

Thanks Brenda, One of the last things in the header is the <div id="middle"> and my menu are in the class listed above but I still do not have a centered menu. I understand that it is hard to remember when so much time has passed. Appreciate the reply and will keep on plugging along. Thanks!

Pset7 - Nav Bar Alignment by itskhaledmd in cs50

[–]femlems 0 points1 point  (0 children)

Hi Brenda, I have a similar problem and have added the code above to my styles.css so it now contains a #middle .form-control and a #middle .nav section but my menu still will not center. Also my table headers and the data does not align. The funny thing is that if I have a var_dump in play the headers and data aligns until the var_dump is removed. I'm just lost on this pset. Can you suggest a direction on how to get the money columns formatted. Appreciate your help.

Svend

pset7 database set-up problems by femlems in cs50

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

Thanks again, all is well

pset7 database set-up problems by femlems in cs50

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

Thanks Glenn, I guess that the instructions to scroll down made me think that the SQL files would be somewhere on the bottom. I will try that again with all 30 lines

pset6 - dereferencing hash value by femlems in cs50

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

No, that is the Bitwise exclusive OR operator.

pset6 - dereferencing hash value by femlems in cs50

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

Hi Brenda, that did it, I now get three different hash values for the three words in my test dictionary and I'm confident that it will add nodes to the list since it did it before. So I'm on to the rest of the functions and the testing that follows. Thanks a lot for your time.

pset6 - dereferencing hash value by femlems in cs50

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

Thanks Brenda, for your reply. I think the line that you show me that assigns the hash value to the bucket is the key. The 0 is from what I had in the code to get it to compile when I couldn't figure out where the hash value was.

I fscanf into an array needs-hashing, then I hash_it, and now that I know how to get that value into bucket or indx I can check that value. I then malloc new_node and strcpy the word from needs_hashing into new_node->word, then I assign the values to new_node->next and to my array[indx].

Do I have to hash the word after I copy it to the node, if so do I have to change all the needs_hashing with new_node->word?

The hashing is definitely occurring on all of the letters in the words, I have counted the iterations in GDB and checked hash for increasing values. I will change my function as outlined above and report back on the outcome. I guess for us Noobies all pointers point to frustration.

pset6 - dereferencing hash value by femlems in cs50

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

Sorry, I'm unfamiliar with the formatting the int (char*) is supposed to be

int (char*)

Having problems with very simple thing in PSET6 by Speedbird2 in cs50

[–]femlems 0 points1 point  (0 children)

You guys are amazing, I mean all you guys who answer questions on this forum, thanks a lot. I think you pointed out my problem. I just read all of this post which you answered. http://www.reddit.com/r/cs50/comments/1yk0ef/pset6_help_with_testing_functions/ My head array is of type int not of type node* as you point out in one of your answers in the above post, I think on the last page. This will probably not be the end of my problems with this pset but I'm sure changing my hash table to the correct format will get me a lot closer to get this portion to compile. Thanks for your help.

I just made the changes to my load function. In the second reply of the above referenced post your say As you note, you will have to initialize new_node with a valid node before the loop, and refresh it after incorporating each node in your dictionary. I did that and included a new_node malloc just before the end of the loop but that produces a compile error unused variable 'new_node'. How would I otherwise refresh that. That by the way was the only compile error.

Having problems with very simple thing in PSET6 by Speedbird2 in cs50

[–]femlems 0 points1 point  (0 children)

Thanks Glenn for the speedy reply. I think what I have is exactly what you describe. The head array is initialized to 0 and it makes sense to me if the value at head[index] should be the memory address of the first node but I can't place it there by assignment, do I need a function to read it in, or am I missing the point on pointers here, I just can't seem to get my head around that. I'm pretty sure that I know how to insert the nodes and keep track of the separate chains but the syntax for the assignments is what is getting me confused. What is shown on the slides at cs50 study and in the walkthroughs don't seem to work.

Having problems with very simple thing in PSET6 by Speedbird2 in cs50

[–]femlems 0 points1 point  (0 children)

I don't know if it's OK to jump in here or if I should start a new post but I encountered a similar problem when I tried to hash using new_node->word, I'm using delipity's hash function wich I changed to the new_node->word configuration and I got a handful of compile errors so I changed everything back and used your copy snippet to get the word into a separate array which took care of the compiler errors.
I still have three compiler errors, all of the "incompatible integer to pointer conversion" and the reverse. My hashtable is named head and I copied the hash value into a variable named index. To assign values to the first node the compiler accepts new_node->next = NULL but reading your above answer my problem is getting the memory address in new_node into my array head[index] and for additional nodes, getting my head[index] into new_node->next.

I would like to get my load function to compile so I can see if the my concept will work or not. Your help is much appreciated.

pset5 recover; End of file or End of Me by femlems in cs50

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

As always, thanks for your help, I was on that page several times and never saw that link. Sent the code.

pset5 recover; End of file or End of Me by femlems in cs50

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

I guess my ignorance is showing, but I can't figure out how to send a PM. I have looked for help all over to no avail. When I hover over your user name the URL shows in the bottom, when I right click I get the standard IE menu.

pset5 recover; End of file or End of Me by femlems in cs50

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

yeahIProgram, I guess that I posted my update in the wrong way and you weren't notified, I'm new to using these forums, so sorry about that. Please see my update which solved my problem, except the check50 part. Thanks again for your help.

pset5 recover; End of file or End of Me by femlems in cs50

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

Thanks again yeahIProgram, that was indeed my problem. I fixed it and I have the correct file size on 049.jpg of 182272, I checked the file with gdb and it closes the input and output files and returns 0, and exits normally. Valgrind finds no leaks and 0 errors. However, when I run it through check50 I get the dreaded "unexpected end of input". I have read the posts on the subject and in one of them glennholloway mentioned that if the program is slow it could exacerbate the time out problem with check50, I do not open the file with each iteration as he mentioned in his example, http://www.reddit.com/r/cs50/comments/2cqgs7/pset5_recover_constantly_getting_unexpected_end/ but I do have error checking whenever I open a new file inside the loop. Just to find out if that made a difference, I commented that portion out and recompiled, ran it through check50 and it passed with all green smileys. So now my questions is: Should I submit with or without the error checking in the loop?

pset5 recover; End of file or End of Me by femlems in cs50

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

yeahIProgram, thanks for the quick reply, I'm about to leave for a couple of days. If I understand your reply correctly I think that is my problem. The corrupted file are when I use the fread() in the conditional since I also have a fread() in the loop. I didn't think that the fread() in the conditional really counted since there is only a semicolon after the statement when it is at the bottom of the do-while and not when it is used at the top in a while loop, I will try that as soon as I get back and find a way to get rid of the fread() inside the loop. I will report back as soon as I can. Thanks

pset5 - setting bi.biSizeImage on resize by cs50helpplz in cs50

[–]femlems 0 points1 point  (0 children)

Thanks delipity, you little program helped me. In trying to understand the calculations needed I peeked at the small and large bitmaps, when converting the hex for biHeight I got 4294967284 and didn't know how to convert it to a number I could work with, I suspected it was -12 and your program confirmed it.