Salem 5,265 Posting Sage

http://www.google.com/search?q=pdf+file+format+specification&ie=utf-8&oe=utf-8
1st link takes you to a 700+ page document telling you all you need to know.

Salem 5,265 Posting Sage

It seems Arbus is more confused about multi-dimension arrays than you are.

> But you are passing multidimensional array. So declare A accordingly (char **A[3] or char *A[3][3]).
But neither of these things are anywhere near char A[][3][3], which is what the OP had to begin with. char (*A)[3][3] would have been OK, but your permutations didn't go that far.


All that was needed was fixing how to pass the array parameter to the function in the first instance. Everything else was OK.

#include <stdio.h>

void displayboard(char board[][3][3]);

int main()
{
  char board[3][3][3] = {
    {
      { "123" },
      { "456" },
      { "789" },
    },
    {
      { "ABC" },
      { "DEF" },
      { "GHI" },
    },
    {
      { "!%^" },
      { "&()" },
      { "+-=" },
    },
  };
  displayboard(board);  //!! No *, & or subscripts here!!
  return 0;
}

void displayboard(char board[][3][3]) {
  int i, j, k;
  for ( i = 0 ; i < 3 ; i++ ) {
    for ( j = 0 ; j < 3 ; j++ ) {
      for ( k = 0 ; k < 3 ; k++ ) {
        printf("%c ", board[i][j][k] );
      }
      printf("\n");
    }
    printf("---\n");
  }
}

Not a single * to be seen!

Salem 5,265 Posting Sage

1) What are the rules of this function structure? A link to a website explaining it would be awesome.
This is how function parameters were defined in what is known as "K&R-C", which existed before ANSI/ISO got in on the act.
http://stackoverflow.com/questions/22500/what-are-the-major-differences-between-ansi-c-and-kr-c

2) What are the advantages of this function structure?
Really old compilers will still work.
> Are there disadvantages?
No cross-function type-checking would be one biggie.

2.A) If there is no difference, Is it just a style of writting parameters? Is there an advantage to the style itself?
No, see above.


2.B) Is there any difference in the machine code generated by the compiler between this style and the standard style?
The caller might generate different code, because it doesn't really know what the prototype for the function should be.

3) Is there a name or term to this function structure? If so what is it?
See above.

4) Is this standard C or is this a gcc extension of some sort?
No, it's a backward compatibility thing for the dim and distant past.

Salem 5,265 Posting Sage

It depends on how you correct your spelling mistake.

http://en.wikipedia.org/wiki/Ellipse
If you want to draw a mathematical figure on screen.

http://en.wikipedia.org/wiki/Ellipsis
If you want to know how something like printf(const char *format, ...); works.

mrnutty commented: exactly what I thought +13
Salem 5,265 Posting Sage

> far and near are reserved keywords in C (not standard, but common, it is a relic from the times of 16bit architectures)
They're reserved identifiers only in compilers for the x86. C itself pre-dates DOS (and the x86), and didn't have these keywords. Likewise, compilers for other languages which ran on x86 also needed to know about the hacky segmented memory models.


What many modern compilers have in some system header file (particularly any with a DOS heritage) are

#define near /*not useful in 32-bit*/
#define far /*not useful in 32-bit*/

So that when used in the correct context, say far char *ptr; // 16-bit would become char *ptr; // 32-bit through the magic of the pre-processor.

But using them inappropriately, say void foo(int near,int far){dofunc(near,far);}//Syntax error, expected primary expression before , and ) expands to void foo(int ,int ){dofunc(,);}//Syntax error, expected primary expression before , and )

kvprajapati commented: Informative! +14
Salem 5,265 Posting Sage

Well on the Linux box, you do this.

gcc -g prog.c
valgrind ./a.out

valgrind will tell you a lot about all kinds of memory abuse (overrun, use after free, uninitialised accesses etc).

When it is clean in valgrind, have another go on windows.

Salem 5,265 Posting Sage

I dunno, what have you been doing all this time?
http://www.google.co.uk/search?hl=en&q=text+extraction+from+heterogeneous+image+using+mathematical+morphology&sourceid=Mozilla-search

> Still date i dont have an any source code or algorithm for extract the text
Well you see, where I come from, a thesis is where YOU do the actual hard work of coming up with something new and unique.

But if your plan was based on "here is a snazzy thesis title, I'll just google (or beg / plead / steal) the answer off the web", then I (and many others) would be quite happy just to watch you fail.

Or as a last resort, just write your phone number on the exam paper
Hey, you got a magic bit of paper saying "pass", but will it mean anyone would want to exchange their money for your time?

Salem 5,265 Posting Sage

Sure is!
Just edit to taste.

Salem 5,265 Posting Sage
WaltP commented: Fantastic!!! +0
Salem 5,265 Posting Sage

> You know you are a geek when ....
You post "You know you are a geek when ...." threads :)
And also reply to "You know you are a geek when ...." threads ;)

Salem 5,265 Posting Sage
Salem 5,265 Posting Sage

For a C++ program, there is precious little C++ in the code at all.

Apart from a few reference parameters (some for no good reason I can see), and the for loop declarations, this could so easily pass for being a C program.

If you want it to be more like C++, then do these things:
1. Replace all printf with cout
2. Replace all char arrays with std::string; for one thing, it reduces strAddChar() to one line of code.
3. Replace all other arrays with std::vector

Somewhere in the code there should be at least one 'class' with suitable member variables and methods.

But then again, you've had only 30 hours, so perhaps making classes is beyond you.

If you've been taught all these things (OK, assuming a level of competence in the teacher here, but what the heck, it might be true), then your tutor is going to be expecting to see some real C++.

So you took someone else's old C and made it make a couple of noises - whoop-ee-doo.

Actually, I don't really care, since we still can't tell what it is you're ACTUALLY capable of doing yourself.

What is for sure is that no one here is interested in helping some wannabe get a grade they don't deserve, which might lead them to getting a job which they are incapable of doing. Unlike student homework, the answers to job assignments CANNOT be found …

Salem 5,265 Posting Sage

Why would someone want explanation for code they've written?

But then again, why bother pretending you can program when you can lift code off the net?
http://cboard.cprogramming.com/cplusplus-programming/132084-cplusplus-snake.html

It's mostly the same code, with a few additions and renames, and some comments in your native language.

jens123 commented: dont want to help, just offend +0
Salem 5,265 Posting Sage

Facebook IS the scam.

http://www.mattmckeon.com/facebook-privacy/
Click through the years, see how the blue "privacy" (joke) spreads with the passing of years. Between their screw-ups, and your ignorance, you may as well just jump in a tar pit, run through a quilt factory and have a big "kick my ass" sign tattooed on your arse. You deserve to be ridiculed and kicked at every opportunity.

The rest is just decoration for the cake.

jwenting commented: well said +0
Salem 5,265 Posting Sage

since my last post

At least it's stopped flashing, but it's still too large where it doesn't matter, and too small and faint where it does.

What hasn't changed is the #1 spot at the top of the reputation ranks.
A whole year without posting, and AD/Narue still couldn't catch up. Gotta admire the volume though AD, well done. Shame it goes under appreciated.
Geez, there's time for the world to end (again) before that changes.

Ohh, activity points - something else to measure quantity as opposed to quality. Figures, most of the top of that list just spam away in posting games. Seriously, saying "me too" 100 times a day is not that impressive.
Do the drive-by spammers hit the top spot on the daily list?

I wonder if anything has been done on the code tags front, or is reporting endless posts for code violations something to look forward to. I suppose we shall see, otherwise this could be a real short trip.

Ezzaral commented: Welcome back +0
vegaseat commented: you are the best then +0
Portgas D. Ace commented: Perhaps grow a pair. +0
debasisdas commented: happy to see you back. +0
kvprajapati commented: Welcome back! :) +0
Ancient Dragon commented: Glad you are back :) +0
jonsca commented: WB +0
~s.o.s~ commented: A bit late to the party, but welcome back. :-) +0
Salem 5,265 Posting Sage

I'm with jephthah - I'm outa here!

The site is an unreadable mess - it's a student summer assignment gone horribly wrong.

The only thing which should actually matter (the stuff people actually contribute) is relegated to the bottom of the pile.

But you all know all this already, so I'll just ...

jephthah commented: i dont know what i regret more: seeing you leave, or having lost my credibility by coming back. :( i'm really torn, because i hate all of the changes to this site. it's gruesome. +0
Nick Evan commented: I'd hate to see you leave, but the choice is yours +0
Salem 5,265 Posting Sage

> What type of developer creates audio plugins for digital audio workstations like pro tools and cubase
Those that need to.
Those that can.

http://www.catb.org/~esr/faqs/smart-questions.html

Salem 5,265 Posting Sage

1.) Describe your current job / job title.
Prime minister of GB - unless those other muppets get their act together.
Dunno then, ask my mate Tone for lecture gigs.

2.) What do you like most about your job?
Spending lots and lots and lots of other peoples money.

3.) What do you dislike most about your job?
Voters

4.) Overall, do you enjoy your job?
Awesome

5.) What kind of education do you have? From what university?
A BA in BS

6.) Any tips for people looking to enter your profession?
Keep talking until people stop listening.
Then start shouting.

7.) (If you don't mind sharing) How much do you make per year?
Salary is crap, but the expenses and benefits are top-notch.

Salem 5,265 Posting Sage

http://lxr.linux.no/+trees
Make sure you have a comfy chair and a lot of coffee on hand - you'll be a while :)

JasonHippy commented: Nice, not seen that site before...bookmarked! +3
Salem 5,265 Posting Sage

Found on several pages after a brief search...
"The most common "C" error code is "0xC000013A: The application terminated as a result of a CTRL+C"

> cin >> junk;
Your "junk" is an int, which means you have to enter something like "0\n" to succeed.
Just pressing return endlessly won't get you past it.
Use say cin.get(); if you just want to wait for a character.

Salem 5,265 Posting Sage

And what pray tell gave you the impression they're using windows?

Salem 5,265 Posting Sage

*shrug*

#include <stdio.h>
int main ( ) {
    int mat[3][3] = {
        { 1, 2, 3, },
        { 4, 5, 6, },
        { 7, 8, 9, },
    };
    int i, r, c;
    for ( i = 0 ; i < 9 ; i++ ) {
        if ( (i+1) % 2 == 1 ) {
            r = i / 3;
            c = i % 3;
            printf( "%d ", mat[r][c] );
        }
    }
    printf("\n");

    for ( i = 0 ; i < 9 ; i += 2 ) {
        r = i / 3;
        c = i % 3;
        printf( "%d ", mat[r][c] );
    }
    printf("\n");

    for ( r = 0 ; r < 3 ; r++ ) {
        for ( c = 0 ; c < 3 ; c++ ) {
            if ( mat[r][c] % 2 == 1 ) {
                printf( "%d ", mat[r][c] );
            }
        }
    }
    printf("\n");
    return 0;
}

$ gcc -std=c99 foo.c
$ ./a.out 
1 3 5 7 9 
1 3 5 7 9 
1 3 5 7 9
Salem 5,265 Posting Sage

> #include<malloc.h> /* You need this if on UNIX or LINUX */
This is all wrong.
malloc is prototyped in stdlib.h

> p = (char *)malloc(sizeof(words));
You don't need to cast malloc in C programs.

Have you tried it without the cast? Did you get any error messages?

These perhaps?
"implicit conversion of int to char*" -> you didn't include stdlib.h
"conversion of void* to char*" -> you're using a C++ compiler to compile C code.

> 4. sizeof() ; function says it all . It means size of the "data" in this case "words".
sizeof is an operator, not a function.
Passing an array to a function yields a pointer to the first element of that array.

The parentheses are optional when applying sizeof to a variable.
p = malloc(sizeof words );

Other issues:
- you didn't check malloc for success
- you didn't describe free(), the essential complement to using malloc.

Salem 5,265 Posting Sage

C'mon - it tells you the line, how many identifiers are on that line?

Do a search for each one of them, and figure out which isn't present.

Hint: identifiers are case sensitive.

kvprajapati commented: Sharp! +9
Salem 5,265 Posting Sage

Eclipse doesn't make sound - it's an editor wrapped around a compiler.

What matters is what your OS is, what API's you have access to and the kind of programs you're creating.

Eclipse runs on many platforms, and can generate project types for many different programs.

So explaining say "sound for a Linux console" wouldn't make a damn bit of use to you if you're interested in "windows GUI programs".

Salem 5,265 Posting Sage
char buff[] = "My dog ate my homework";
char *p = buff;
int n;
while ( sscanf( p, "%s%n", word, &n ) == 1 ) {
  p += n;  // advance through the buffer
}

> PS: Does anyone know why firefox is showing "behavior" as a wrong spelling while I am typing here in this text area?
You install the dictionary for your flavour of English.
So things like colour are spelled correctly ;)

tux4life commented: Then my science project ate my dog :P +8
kvprajapati commented: I've added [code]s after five days (below). Bad colour scheme. +9
Salem 5,265 Posting Sage

How about posting your attempt.

Rather than just describing to us rather unconvincingly that you've made any attempt at all.

We get a lot of "I tried but it didn't work, here's my question, can you do it for me, kthxbye" types.

Salem 5,265 Posting Sage

Weird - your printf statement looks exactly the same, except for the fact that you said you changed it.

Thanks for playing.

jephthah commented: i feel your pain +7
Salem 5,265 Posting Sage

Did you compile it?

I mean this is 6 hours later, and it's at best a 30 second job to write a few line test program to see if you can do
Real myvar = 1.0;

Salem 5,265 Posting Sage

http://www.daniweb.com/forums/announcement8-2.html

If you don't even understand the question, then go and talk to your tutor.

If you're stuck on part of the answer, then post some relevant code and ask a question about that code (in the context of your problem).
Eg. I think I need a list of bids, but my list keeps dropping the latest bid. Here is my code.


Don't just dump your assignment fresh from the email message from your tutor then sod off down the beach or something, expecting us to take up your slack - it ain't gonna happen.

Salem 5,265 Posting Sage

In my time off, I like to collect spammer addresses whilst putting the finishing touches to my latest toy.

The ICE Man commented: LoL :) +0
Salem 5,265 Posting Sage

Here's why your "I want" is going to fall on deaf ears.
http://www.daniweb.com/forums/announcement61-2.html

If you want it badly enough, make an effort.

Otherwise, just drop the course now and stop sucking the life out of whatever class you're in.

kvprajapati commented: Well said. +9
Salem 5,265 Posting Sage

Are you trying to make me believe you got the ; in the right place?

The only thing I would do with that code is press CTRL-A then press DEL.

Salem 5,265 Posting Sage

Load first map from file
Play level
Load second map from file
Play level

If loading a map takes a few seconds then
Load first map from file
Play level
Display some static image and play "tension" music in the background
Load second map from file
Play level

jonsca commented: Rep for recommending the "tension" music -- good touch +4
Salem 5,265 Posting Sage

> int dataLen = recv(client, recvBuffer, 1024, 0);
You're assuming several things (all of which are false, eventually)

1. That for every "message" sent, you get "message". STREAM sockets can fragment the message (only the byte order is guaranteed). So you might get "mess" or even "messagemessageme".

2. That every message has a \0 (to make it a proper string). If you don't send one, then there isn't one added automatically.
Typically, this means using sizeof(buff)-1 in the recv call to allow for easy appending of a \0 if you need to.

3. Use the length before doing anything else with the message.
len = recv....
if ( len > 0 ) buff[len] = '\0';

Then you can treat buff as a proper c-string.

iamthwee commented: Good ol' fashioned advice, full of that ying yang goodness. +11
Salem 5,265 Posting Sage

So why can't you recursively evaluate A -> B -> C ?

a1 = eval( eval(a2) + eval(a3) );

When you get to a3, you see that you need to do another eval()

Is this a plan?

The only problem you need to watch out for is if there is a cycle in the expressions.

Salem 5,265 Posting Sage

That's a spectacularly useless manual page AD.

Not only is there no %n, there's no %i %p or %[ either.

http://linux.die.net/man/3/scanf
Which includes all the ones new for C99 as well.

Salem 5,265 Posting Sage

*shrug*
I just threw in some crumbs to show the general idea of how the problem was solvable.

Tarting it up for security and suitable for compiling with whatever C.X.Y compiler was left as an exercise for the readers :)

Aia commented: You know what it is said about "Do not throw pearls before swine". But crumbs are OK. ;) +8
tux4life commented: Oh, okay, maybe I "overreacted" a bit. +8
jephthah commented: "tarting it up" ... that will be my new phrase +7
jonsca commented: I left my English to English dictionary somewhere... +4
Salem 5,265 Posting Sage
int s, e;
scanf(" %n%s%n %d", &s, R, &e, &n);
int len = e - s;
tux4life commented: Nice :) +8
kvprajapati commented: N/A +9
Salem 5,265 Posting Sage

No, you're wrong.
argc is a COUNT of the number of arguments, it has nothing to do with the value of any single argument.

All the args are in argv[] as a series of string, which you need to covert.

So a long long int would be a string in argv[1] with
./myprog 1234567890987654321

Salem 5,265 Posting Sage

You could pad your format string with %n conversions, which would give you a length with a minimal calculation.

Salem 5,265 Posting Sage

Because passing an array to a function reduces it to just a pointer to the first element, and the size information is lost.

Just like it were a regular function.

Salem 5,265 Posting Sage

It's quite clear by now that this thread is nothing but a magnet for sig-spammers with it's high view count

jephthah commented: tru dat +0
Salem 5,265 Posting Sage

400*400 is 160000

This is somewhat larger than the 16 bits (max 32767) that your ancient TurboC compiler can manage.

UPGRADE!

Salem 5,265 Posting Sage

You could post some ACTUAL code, not 1-line entries out of the API manual.


Then there's the spam
http://www.daniweb.com/forums/post1203148.html#post1203148

donaldw commented: Spam? The problems and questions are entirely different! +0
kvprajapati commented: N/A +9
Salem 5,265 Posting Sage

A fine coat, made from the skin from the fingers of 1000 spammers.

As well as being a somewhat rare commodity, the beneficial side effect is that 100 of them can no longer type :icon_twisted:

BestJewSinceJC commented: Haha, you're stuck on spammer hate! +0
Salem 5,265 Posting Sage

Most of the IDEs I know save the compilation/interpretation to external tools.

So a simple wrapper around
- edit file using an editor
- pass file to compiler
- gather error messages.

All of this is mundane stuff compared to writing a compiler.

Maybe grab the source code for code::blocks and start reading.

Salem 5,265 Posting Sage

The same code was round a few days ago, including the same mistakes.

My guess is that this is a "fix the errors" homework assignment just dumped on the board.

jephthah commented: thanks for the tip. now i won't waste my time on it. +7
Salem 5,265 Posting Sage

> Can you give me an example.
What are you on about (or how helpless are you)
http://www.mega-nerd.com/libsndfile/command.html#SFC_CALC_SIGNAL_MAX
There - in large letters for anyone with eyes to see - the word "Example" followed by a snippet of code.

JasonHippy commented: My point exactly! +2
Salem 5,265 Posting Sage

Here is a function pointer tutorial
http://www.newty.de/fpt/fpt.html

> I have attached below a very simplified version of my actual code.
A simplified version that actually compiles would help.
Like what is fct() on line 55?

Sure, you have to leave a few lines commented out where the trouble is, but if we fix that, then it should work.

kvprajapati commented: Great link. +9