Unrelated! (Source code section)

Pages: 1234
Am I the only one who can't download attachments? For example, when I click on http://cplusplus.com/articles/oGE1wA7f/stopWatch4_windows.zip Chrome doesn't download it but opens it as a text file and displays garbage..

ÀV2ÞÂíÛr9~ȳ"´(ù <J*<ãpµ¸
{z,ï ÑR{Ñi}
Nope. I have the same problem, though I am using the same browser.

I am using firefox, yet still see garbage :-/
Last edited on
Maybe content-type field in HTTP header is always being set to text/html?
Last edited on
Am I the only one who can't download attachments?

Right-click, Save As.
closed account (D80DSL3A)
Yeah it was frustrating trying to make the attachments work. That's why I also gave links in the body of the article to the files on mediafire.

I notice the links in the article aren't 'hot' but I think this one is here:
zip file: http://www.mediafire.com/?1g5bbi5mwlxj1bo
¿Why the pdf extension?
main.pdf: ASCII C program text, with CRLF line terminators
Archive:  stopWatch4_windows.zip
  End-of-central-directory signature not found.  
  Either this file is not a zipfile, or it constitutes one disk of a multi-part archive.

¿What about the images in that other post?
Last edited on
closed account (D80DSL3A)
I gave the files a .pdf extension because only .pdf files could be attached.
I see that .h, .c, .txt and .cpp files are now allowed. When I posted the article these other file types would not be accepted.
I've tried editing the list of attachments, but now the problem is that line breaks are not recognized.
Attached .h and .cpp files appear as continuous text with no line breaks, which makes them unreadable.

If I can figure out how to get attached files to appear as they do in notepad I will edit the article.
Does anyone know how to make that work?

Embedding an image works fine with the use of <IMG SRC="filename.png"> so that is nice.
closed account (D80DSL3A)
Please tell me if this is stupid!!

Of course, if you're going to say that, then please also tell me how to do this correctly.

I'm trying to get files attached to an article to appear as desired.
The file types .h and .cpp can now be attached to an article. That's great but...

Problem #1: Line breaks are ignored. The text appears as continuous with no line breaks. As I noted in my last post this makes the file contents unreadable.

Possibly stupid solution to problem #1: I have written a program which reads each line from a given file, appends the HTML tag <BR> to each line, then writes the line to an output file.
This works! The line breaks are forced as desired.

Problem #2: The translated file now looks like it does when code tags are not used in a forum post. Tabs are not respected. I want the indentation preserved.

Attempted solution to stupid problem #2: Have the translation program (mentioned above) also count the number of '\t' characters found at the beginning of each line. If any are found, erase them and substitute " " (4 blank spaces) for each one.
Unfortunately, this does not work. It appears that leading whitespace gets eaten too (as occurred between the quotes 3 lines above - I put 4 spaces there).
There is a list of acceptable HTML tags that can be used for formatting in the "Format help" section: http://www.cplusplus.com/articles/help.cgi but there is no tag for insertion of a tab space. I have no other ideas for solving this problem.

If someone knows how to to get attached source code files to appear as they do in, say, notepad, then please tell!

Use of the <SOURCECODE> </SOURCECODE> tags mentioned in the help section doesn't seem to work for attached files either.

P.S. The problem with attached .zip files appearing as garbage seems hopeless so I've given up on trying to attach those. Any ideas about the .zip file attachment problem?

The problem with attached .zip files appearing as garbage seems hopeless so I've given up on trying to attach those. Any ideas about the .zip file attachment problem?

... that problem is minor, the files can still be downloaded fine, as I wrote in my previous post.

So I suggest that you simply ZIP up your code, because if your contribution uses more files than one I highly doubt anyone would care about the ability to download single source files.
closed account (D80DSL3A)
@Catfish. I did try
Right-click, Save As.
after seeing your earlier post.
Perhaps it's an XP thing but there is no 'Save as...' option on right click. There is a 'Save page as...' option. Despite giving the file a .zip extension the file gets downloaded and saved as filename.zip.htm. This downloaded file appears as garbage also, so it does not work.
Downloading from the link in the article: http://cplusplus.com/forum/lounge/59547/3/#msg323466

The files shouldn't be treated like html.
fun2code, in IE is is Save Target As.
closed account (D80DSL3A)
LB Thank you. That worked using IE.
The .zip file had no files in it. Perhaps I uploaded a corrupt file.
I will try again to attach a .zip which I have verified to be good.

@Catfish. I see your point about putting all files into the one .zip file.

EDIT: I have modified the article and have attached a new .zip file.
I have eliminated the links to individual source files and just put everything in the one .zip file, per Catfishs suggestion.
When the new version goes live (following a review) would someone please let me know if they succeedded in extracting the files and running the program?
The article is titled "A win32 multi-function stop watch using SFML" in the source code catagory.
Last edited on
Something I'd very much like to see is sample code of basic data structures. I've implemented quite a few myself, but am often left with the feeling of "There should be a better way of doing this...". I'd love to see how more experienced programmers do it.
@ fun2code: download works fine. http://www.freeimagehosting.net/6zxld

@ Gaminic: I don't know how you could give a general example for something as specific as data structures... what exactly do you mean?
Just an example of how to implement a basic vector, linked list, BST and binary heap. A "general example" would be using a very simplistic item to store. Ultimately, the satellite data doesn't matter; just the pointer/key work, so a generic version is easily translated into a specific one.

For example, most Linked List code sample code I've seen uses dynamic allocation (pItem->next = new Item;) and recursive deleting (~Item() { delete this->next; } ) to get the entire LL deleted. I, on the other hand, tend to keep my elements in an unorganized array and have the links internally. I imagine there are advantages to each method, but it's difficult to analyze the performance by yourself if you're a beginner.
I thought the whole point of a linked list was to have a performance gain from not reallocating the entire list to expand it? If you're using arrays internally that sounds like it's completely overshooting the point of a linked list ;p
That depends on the application at hand. If you're keeping a single list, you're obviously correct!

However, in my case, the point is usually that a set of N items has to be divided over K subsets. Any case ranging from {0, 0, ..., N} to {N/K, N/K, ..., N/K} is possible. N and K are known at "initialization time", but the distribution over subsets is completely random. Internally-linked lists work like a charm here.
Does anyone actually have non-trivial programs they'd like to put there?

I'm planning on writing a few programs to do some research/documentation on the development environment. I will consider posting a peer-review type thread and then submitting them here.

I'm open to ideas as far as the projects go.
Pages: 1234