LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-11-2017, 11:11 AM   #1
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 4,692

Rep: Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865
is blank or corupped files a bit of a norm when loading a link list?


this is a rewrite of an earlier post, because that was redundant and I got it working again and this is my where I am at now. leaving me wondering as this is the very first time I've dealt with link list.


Code:
typedef struct myList mylist;

struct myList
{
char *filename;
//mylist *curr;
mylist *next;
mylist *prev;
};
when I load it and print it out - do not get everything or is it getting corrupted data (image files)?

Last edited by BW-userx; 08-11-2017 at 01:28 PM.
 
Old 08-11-2017, 12:29 PM   #2
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 4,692

Original Poster
Rep: Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865
well I got it half working: I got 8 files split between rootDir and RootDir/SubDir - it is stil not picking them up properly.. I suppose this is a normal day for programming?

printlist(); total files in linked list and names
Code:
in get_next_name_in_list ) list_length 8
BLALALALA image /media/data/test/sub1/DispicableMe-1-10724.png
header->filename 
header->filename /media/data/test/sub1/DispicableMe-1-10724.png
header->filename /media/data/test/sub1/DispicableMe-1-10624.png
header->filename /media/data/test/sub1/DispicableMe-1-10524.png
header->filename 
header->filename /media/data/test/DispicableMe-1-11124.png
header->filename /media/data/test/DispicableMe-1-11024.png
header->filename /media/data/test/DispicableMe-1-10924.png
filename /media/data/test/sub1/DispicableMe-1-10724.png
PRINT  LIST MAIN
header->filename Me-1-10724.png
header->filename /media/data/test/sub1/DispicableMe-1-10724.png
header->filename /media/data/test/sub1/DispicableMe-1-10624.png
header->filename /media/data/test/sub1/DispicableMe-1-10524.png
header->filename 
header->filename /media/data/test/DispicableMe-1-11124.png
header->filename /media/data/test/DispicableMe-1-11024.png
header->filename /media/data/test/DispicableMe-1-10924.png
userx%slackwhere ~ sixth-run ~>
Code:
userx%slackwhere ~ sixth-run ~ > ls -l /media/data/test/*
-rwxrwxrwx 1 userx users 1353872 Jun 28 17:24 /media/data/test/DispicableMe-1-10824.png
-rwxrwxrwx 1 userx users  915481 Jun 28 17:24 /media/data/test/DispicableMe-1-10924.png
-rwxrwxrwx 1 userx users 1147328 Jun 28 17:24 /media/data/test/DispicableMe-1-11024.png
-rwxrwxrwx 1 userx users  792994 Jun 28 17:24 /media/data/test/DispicableMe-1-11124.png

/media/data/test/sub1:
total 3800
-rwxrwxrwx 1 userx users 1112183 Jun 28 17:24 DispicableMe-1-10424.png
-rwxrwxrwx 1 userx users  926284 Jun 28 17:24 DispicableMe-1-10524.png
-rwxrwxrwx 1 userx users 1261418 Jun 28 17:24 DispicableMe-1-10624.png
-rwxrwxrwx 1 userx users  582170 Jun 28 17:24 DispicableMe-1-10724.png

Last edited by BW-userx; 08-11-2017 at 12:31 PM.
 
Old 08-11-2017, 12:47 PM   #3
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 4,692

Original Poster
Rep: Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865
this is the only thing I am now wondering about - as you can see I pulled in 520 files, and before it was only 8 files, Post #3 above -

It is them few beginning files that are "blank" or corrupted? I know not which, but is that a normal thing, nature of the beast when working with link listed? (my first time here).

if yes, then I'm betting their is a way to check for that and have the list skip and go to next in order to not send a blank or corrupted file associated with that one struct (node) ?

or if no, then I got more figuring it out to do.


Code:
in get_next_name_in_list ) list_length 520
BLALALALA image /media/data/wallpaper/arer/Img-0966.png
header->filename 
header->filename /media/data/wallpaper/arer/Img-0966.png
header->filename /media/data/wallpaper/arer/Img-0906.png
header->filename /media/data/wallpaper/arer/Img-0846.png
header->filename /media/data/wallpaper/arer/Img-0786.png
header->filename /media/data/wallpaper/arer/Img-0726.png
header->filename /media/data/wallpaper/arer/Img-0666.png
header->filename /media/data/wallpaper/arer/Img-0606.png
header->filename /media/data/wallpaper/arer/Img-0546.png
header->filename /media/data/wallpaper/arer/Img-0486.png
header->filename /media/data/wallpaper/arer/Img-0426.png
header->filename *ˆ
header->filename 
header->filename /media/data/wallpaper/arer/Img-0366.png
header->filename *ˆ
header->filename /media/d

Last edited by BW-userx; 08-11-2017 at 12:49 PM.
 
Old 08-11-2017, 02:34 PM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 3,242

Rep: Reputation: 982Reputation: 982Reputation: 982Reputation: 982Reputation: 982Reputation: 982Reputation: 982Reputation: 982
Guessing from the information you gave, I would think there might be some problem with something.
 
2 members found this post helpful.
Old 08-12-2017, 08:01 AM   #5
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 4,692

Original Poster
Rep: Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865
Quote:
Originally Posted by NevemTeve View Post
Guessing from the information you gave, I would think there might be some problem with something.
yep!
without going into it tooooo much,

I got tried of looking for what was causing it. I think I picked up enough scraps on what and how to do the basic parts of this by using their code and seeing what and how it does what it does. Just wasn't happy with how they were doing it. I didn't need all of that over kill stuff so I striped it all out yesterday.

Then I redid just about everything again (keeping my own stuff I did of course) Then using a different method rewrote a lot of it from scratch yesterday so I'd actually know what it was doing.

So now it appears to be working correctly in loading the files. Just ran out of time last night. Mostly searching on how to actually do more then just declare and define a struct. - typedef extern etc..

Which is everywhere on the Internet. Its like showing someone how to put the key into the ignition, but after that they're on their own to figure out how to get it to do what they need it to do.

Then seeing ever ones way of doing the same thing causing a bit of confusion.

Just putting all of the pieces together to get it to work the way I want it to. Time consuming.


Just want to get this part to where I am satisfied with it before moving on to error checking then putting some bells and whistles in it.


First times can not always be easily accomplished. James Corbin 1304

MOD:

haha now I'm happy fix my one function to get the file after loading the list and it work on the first try.
cheers!

Last edited by BW-userx; 08-12-2017 at 09:09 AM.
 
Old 08-13-2017, 01:39 AM   #6
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_10{.0|.1|.2}
Posts: 4,468
Blog Entries: 6

Rep: Reputation: 2409Reputation: 2409Reputation: 2409Reputation: 2409Reputation: 2409Reputation: 2409Reputation: 2409Reputation: 2409Reputation: 2409Reputation: 2409Reputation: 2409
Quote:
Originally Posted by BW-userx View Post
this is the only thing I am now wondering about - as you can see I pulled in 520 files, and before it was only 8 files, Post #3 above -

It is them few beginning files that are "blank" or corrupted? I know not which, but is that a normal thing, nature of the beast when working with link listed? (my first time here).

if yes, then I'm betting their is a way to check for that and have the list skip and go to next in order to not send a blank or corrupted file associated with that one struct (node) ?
No, corrupted data is certainly not normal for any type of data storage or manipulation! If your data are being corrupted then you need to fix whatever is happening to corrupt it!

But you have not shown us anything relevant other than your list node struct.

The list of five or five thousand files and what they are used for is not relevant or useful for anyone to try to help.

In your other thread you change list element pointers within a loop which is supposed to be returning successive list memebrs, and thus corrupts the list. If this is the same application then that is certainly something that must be fixed.

You need to troubleshoot each part of your code in isolation.

First, validate your node create function - does it in fact create a valid node with valid data and valid linkage to the list? Can you say that with certainty?

Next, if separate from your node create function, validate your list append function. Does it properly append to the list - with certainty?

Then, if you support node deletion, validate the node delete function - with certainty!

Finally, validate your list traversal function(s). Does it or do they properly traverse the list? Do they know when they reach the end? Do they know how to return to the head? With certainty?

Only then try to use them in your application. If you then need help with any of those, post the relevant code without your application details so that others may help you more effectively.

Also, please post your questions only once and do not mark them solved unless they contain a useful solution. You may want to mark them and move on, but others looking for similar solutions will find a thread marked SOLVED which in reality does not include a solution, degrading their own LQ experience. As these two threads now have multiple posts I think it would be more confusing to merge them, so they will remain separate at this time.
 
Old 08-13-2017, 01:28 PM   #7
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 4,692

Original Poster
Rep: Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865
Quote:
Originally Posted by astrogeek View Post
No, corrupted data is certainly not normal for any type of data storage or manipulation! If your data are being corrupted then you need to fix whatever is happening to corrupt it!

But you have not shown us anything relevant other than your list node struct.

The list of five or five thousand files and what they are used for is not relevant or useful for anyone to try to help.

In your other thread you change list element pointers within a loop which is supposed to be returning successive list memebrs, and thus corrupts the list. If this is the same application then that is certainly something that must be fixed.

You need to troubleshoot each part of your code in isolation.

First, validate your node create function - does it in fact create a valid node with valid data and valid linkage to the list? Can you say that with certainty?
I cannot say anything with certainty. I'm like a blind man in a fish store.
I've never done this before, so I have no idea what to show anyone in that first place. So i just give what i am looking at using to try and figure out why that list when printed out is missing files and has them weird looking chars within them.


Quote:
Next, if separate from your node create function, validate your list append function. Does it properly append to the list - with certainty?

Then, if you support node deletion, validate the node delete function - with certainty!
still a blind man here, but just to day I was thinking about this, and might as well say it in here, is there a quick start read for that DDD - debugger GUI i just heard about? Because I already took a quick look at that docs on it and do not want to spend hours sorting through it to find just the few simple things I need to know just to fire it up and run my code through it and give me human feed back as memory address are Greek to me.
anyways ..

Quote:

Finally, validate your list traversal function(s). Does it or do they properly traverse the list? Do they know when they reach the end? Do they know how to return to the head? With certainty?

Only then try to use them in your application. If you then need help with any of those, post the relevant code without your application details so that others may help you more effectively.

Also, please post your questions only once and do not mark them solved unless they contain a useful solution. You may want to mark them and move on, but others looking for similar solutions will find a thread marked SOLVED which in reality does not include a solution, degrading their own LQ experience. As these two threads now have multiple posts I think it would be more confusing to merge them, so they will remain separate at this time.
as to so all of this process other then what I do do, which is write my code, and compile just that c file with its header attach separately to see if it shows me any errors or warnings first. then attach it to the rest of my files then incorporate it into the rest of the conglomeration.

so let me be a quick study where do I find how to do all of what you've said to ensure this, as I have been wanting to find a means to even follow the code flow in here which a debugger would let me do, but as I have said I set that who know how long that will take to figure out by using their documentation on how to use it, when I do not want to use it for all of that in which they wrote it to be able to do.

I'd just need to see where the functions go and what kind of data I am getting within my code and to make sure it is following the path I want it to a well.

so Now I am guessing the best lead in question for me to give is what do I need to post for this "certain" problem?

but I really need to stop using LQ for a crutch. meaning like me after five hours of trying to figure out something and getting frustrated and whatnot - still wait another day and trying some more before allowing myself to post a question.

Last edited by BW-userx; 08-13-2017 at 01:33 PM.
 
Old 08-14-2017, 02:27 AM   #8
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_10{.0|.1|.2}
Posts: 4,468
Blog Entries: 6

Rep: Reputation: 2409Reputation: 2409Reputation: 2409Reputation: 2409Reputation: 2409Reputation: 2409Reputation: 2409Reputation: 2409Reputation: 2409Reputation: 2409Reputation: 2409
You remain a blind man in a fish market only because in your haste to get to the next fish tank, you never really looked at what was inside the previous one!

Claiming to be a blind man (novice in any realm) is another form of crutch in that it makes a kind of excuse for having not seen things more clearly (and for not trying to correct that condition).

My best advice would be: Stop trying to make things work now saying that you will learn them later - things will not work and you will never learn! It takes many times as long to do everything quickly, and incompletely, than to take time out to learn each essential concept well. Stop punishing yourself, and stop making excuses to and for yourself.

Learn the essential concepts in isolation by writing your own simplest, trivial test cases to explore them. When you try to implement some idea new to you directly into your live application, you end up with a mess - been there, done that!

For example, a linked list is not "thing" that you copy and paste, nor code blocks that you adapt. It is an idea, a concept, a model useful for visualizing and implementing data structures. Learn the essentials of the model first, only then try to write code using the applicable concepts of that model to solve some real world problem. All programming concepts are like that - ideas, concepts and models, not essentially code.

And debugging tools have their place, but don't think that a debugging tool is a shortcut or a substitute for understanding what you are doing. It will just become another kind of clumsy crutch! If you do not understand how a thing should work, then you will not know how to interpret debugging output when it doesn't and it can actually become a further impediment to understanding.

Hope these comments are helpful!

Last edited by astrogeek; 08-14-2017 at 02:30 AM.
 
2 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get correct link speed for bridge device? Most list unknown/Invalid links speed. kandresen Linux - Networking 2 08-11-2017 09:56 AM
[SOLVED] Is this code logic correct? santosh0782 Linux - Newbie 1 02-16-2014 01:44 AM
how to make link list and add and delete list node in shared memory golden_boy615 Programming 1 12-18-2011 06:52 AM
Missing Link- Fill With Logic inescapeableus Linux - Software 12 09-05-2004 03:31 PM
is this link correct for cdrom? ziggie216 Linux - Hardware 9 11-11-2003 03:13 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration