Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 60: The memory allocated here is destroyed by lines 75 and 80 -- memory leak.

I don't get what parser() is supposed to do.

This is a sightly modified version of readXml function compiled with VC++ 2010 Express on Windows 7. It does not contain the problem you reported. All I did was removed malloc(), there is no point allocating memory for only 4 bytes of data. Also simplified the if-else clause in that function.

#include <stdio.h>
#include <stdlib.h>
//#include <unistd.h>
#pragma warning(disable: 4996)
#define BUFSIZE 4


void error_handler(unsigned short int err) {
    char * error_desc;
    switch (err) {
        case 1: error_desc = "Input file could not be opened.\n";
            ;;
        case 2: error_desc = "Input file did not exist.\n";
            ;;
        case 3: error_desc = "Output file could not be opened\n";
            ;;
        case 4: error_desc = "Output file could not be closed.\n";
            ;;
        default: error_desc = "Unspecified error, aborting.\n";
            ;;
    }
    printf("Exiting with error %s\n", error_desc);
    exit(err);
}

FILE * openFile (char * filen_in, char * mode, unsigned short int err) {
    /* Open SAFT file.          */
    FILE * fp;
    if ((fp = fopen (filen_in, mode)) == NULL) {
        error_handler(err);
    }
    return fp;
}

void closeFile (FILE * fp, unsigned short int err) {
    /* Close output file.       */
    if (fclose(fp) != 0) {
        error_handler(err);
    }
}

char * parser(char ** p, unsigned int dif)
{
    /* Store first 2 chars of each string */
    /* printf("-------------- %d    %d  \n", p, *p);*/
    if (dif > 0) {
        ++*p;
    }
    return …
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

CV

What's that? > book, CV, article.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yes! Got ~~~ working :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Testing

int nTransistors;
char ManID[20];
char Polarity[20];
// populate the above with info now shown here
printf("%d %s %s\n", nTransistors, ManID, Polarity);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Oops! It did work. I just have not gotton used to refreshing the browser after doing something. I just now went back to the thread where I was posting and the code tags worked afterall :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I tried using [code] and [/code] but that doesn't work. I tried using the Code button but that didn't seem to work either (i.e. past code into editor, highlight, then hit the Code button). So how to add code tags?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

depends on how you declared data that contains the individual items. Something like this:
.

int nTransistors;
char ManID[20];
char Polarity[20];
// populate the above with info now shown here
printf("%d %s %s\n", nTransistors, ManID, Polarity);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

also google spell check doesn't work for me anymore as im typing typing this ,and i need spell checker

So that's why I suddenly became so brilliant :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You can't use cin >> name and expect to get a string with spaces. call getline() instead so that it will capture spaces within the string

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Unfortunatly i do not know C

C is not really a prerequisit for learning c++ unless your instructor and school says it is.

The requirements you posted for the program are pretty vague. Is that all the info you were given?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Can someone please answer this for me as i cant do this practice question

No, we do not do homework for people. Give it a try then post what you have attempted.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I won't know until you post all the code.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The problem could be line 15: many older compilers don't like declaring variabes anywhere except at the beginning of a block enclosed in { and }. That's ok with c++, but not C.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

My guess is that readST() is trashing memory, and when that happens it can affect anything or everything ion the program. There is nothing in the code you posted that should cause the problem because all it does is open and close the files.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I think I figured out the edit button problem. I'm using Chrome and have to hit the page refresh button in order to get the edit button to show up.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Probably permissions then.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I a getting a bunch of db errors. Below are just a few of them

Deprecated: Assigning the return value of new by reference is deprecated in /home/daniweb/pfo_httpdocs/includes/init.php on line 49

Deprecated: Assigning the return value of new by reference is deprecated in /home/daniweb/pfo_httpdocs/includes/init.php on line 97

Deprecated: Assigning the return value of new by reference is deprecated in /home/daniweb/pfo_httpdocs/includes/init.php on line 101

Deprecated: Assigning the return value of new by reference is deprecated in /home/daniweb/pfo_httpdocs/includes/init.php on line 109

Deprecated: Assigning the return value of new by reference is deprecated in /home/daniweb/pfo_httpdocs/includes/init.php on line 120

Deprecated: Assigning the return value of new by reference is deprecated in /home/daniweb/pfo_httpdocs/includes/init.php on line 124

Deprecated: Assigning the return value of new by reference is deprecated in /home/daniweb/pfo_httpdocs/includes/init.php on line 132

Deprecated: Assigning the return value of new by reference is deprecated in /home/daniweb/pfo_httpdocs/includes/init.php on line 201

Deprecated: Assigning the return value of new by reference is deprecated in /home/daniweb/pfo_httpdocs/includes/init.php on line 378

Deprecated: Assigning the return value of new by reference is deprecated in /home/daniweb/pfo_httpdocs/includes/class_core.php on line 2514

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Chicago' for 'CDT/-5.0/DST' instead in [path]/includes/functions.php on line 3388

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. …

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Ok, so now I see Edit Post and Flag Bad Post on the above two posts. But I still don't get Edit buttons on C forum

[edit]Correction: I see it now. You must have been in the process of changing it when I posted this.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

why a character array isn't being recognized as a pointer already.
The reason is that you have hidden the global char array named "input" with the local parameter with the same name. In such cases the compiler ignores the global variable.

To correct the problem delete the global array and make it local to main(), then on line 10 make the parameter an array.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you will have to call strlen() to get the length of each string, add them together + 1 and malloc that much space. OR you can call realloc() in the same loop where you concantinate the strings, but you still have to call strlen() to find out how much you have to expand the destination string.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 10: > )malloc(sizeof(argv)

Wrong. sizeof(argv) is always 4 because its a pointer.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

All I see is Show Comments and Flag Bad Post. No edit button.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

All I see is Show Comments and Flag Bad Post. No edit button.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

^^^ failed

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

\"d".mkv\" <<< test with back quote

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

^^^ failed

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Now lets try it with code tags
"d.mkv"

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

See, it did it again in the above post. Hould have been (without spaces) "% 0 2 d.mkv"

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

See my last two or three posts here: http://www.daniweb.com/software-development/c/threads/418582/system-function-problem

When I enter "d.mkv" the editor removes everything but d.mkv. Not good when posting code.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

try it again

% 0 2 d.mkv

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I hate not having an edit button!!!

"d.mkv"

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The above should have been "d.mkv"

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

/* For the episodes that have 0 before the number e.g 01..09 */

That's not necessary. Just use "%0.2d" and the number will have 0 before the first digit if there is only 1 digit.
char buf[50];
sprintf(buf,"\"C:\wamp\www\anime\kenshin\Rurouni Kenshin - %0d.mkv\" \"%d.mkv\"", count, count);

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You have to format the string with sprintf() before passing it to system() or rename() functions -- those functions don't work like printf().

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Double-click on code to copy/paste it.

Great :) That answers my previous question about that topic. That is a litte easier than previous version of DW.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Because he has a drop-dead gorgous wife and takes no shit of anybody.

Why is Austraila down under? Under what?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

There was immense pressure to get this system rolling before a hard and somewhat unreasonable deadline,

Huh? Ms Dani owns DaniWeb so there should be no pressure to upgrade, she is free to do what she wants when she wants to. Only Ms Dani makes the deadlines.

But I'm not about to stop visiting DaniWeb just because there are a few problems with it now. It's still a great community.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The Edit post button is not available here in Community Feedback forum, which is probably a permissions problem because I have it in the Software forums.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yes, I see both buttons. Reason should not be reqired unless person editing the post is a mod or admin

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

In a loop, convert each byte to binary then add to an int accumulator, for example assume you have a character array named "msg" and a loop counter named "i"
sum = (sum * 10) + msg[i] - '0';

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I don't think this works. I tried it in http://www.daniweb.com/community-center/daniweb-community-feedback/threads/418509/copying-code-to-clipboard- then went to the forums in the tags and my post did not show up in those forums.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

while(fread(ar, 1, 20, file) != NULL)
That only reads 20 bytes of data instead of 20 * sizeof(int) number of bytes. You need this?

while(fread(ar, 20, sizeof(int), file) != NULL)

how read one line at a time,
You mean how to read one integer at a time?

int i = 0;
while( fread( &ar[i], 1, sizeof(int), file) != NULL)
   ++i;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Will you please add a button to quickly copy code inside code tags to clipboard? I find it really annoying and inconvenient to use the mouse to highlight all the code inside code tags, it was a lot easier in the vBulletin version.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The conversion will fail on languages that require more than one byte to represent a character such as many Chinese and Japanese glyphs

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I saw that same problem yesterday. No edit button

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Is PFO coming back anytime soon? It's been swamped with spam the past few days, but I hope you will bring it back soon.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I see no way to edit a post. How can we do that?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Are you talking about moderator permissions? I have not seen a permissions problem.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>how do i pass these to the functions in the driver file?

The file that contains main() is considered the "driver file". In your first code snippet all you have to do is include the header file that you created, like this

#include <iostream>
#include "myheader.h" // <<<<<<<<<<<<<<<<<<<<< here

int main()
{
  dispenser MyDispenser; // declare an object of type class dispenser
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What compiuler? What operating system? What language? We need a lot more info.