deceptikon 1,790 Code Sniper Team Colleague Featured Poster

let's put it in simple words, the subquery in this code will return on a boolean value TRUE, ok ?

It will select a matching record. exists evaluates to a boolean based on the presence of any matches. But the rest of your explanation is reasonable, though not strictly correct (which is okay since you're putting it into simple words). I think the issue here may be less about exists in particular and more about relational logic in general.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

exists looks for the first match in the subquery. If it returns true for any of the matches in the outer query, the where clause succeeds and that record will be selected.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

How about a different example? Let's say you have customers that have the option to enrole in a feedback survey. You want to get all of those customers to send survey emails. You could use exists to retrieve that list and exclude customers that didn't enrole.

select c.ID, c.Name, c.Email
from Customers c
where exists (select * 
              from SurveyEnrolement se
              where se.CustomerID = c.ID);

Not that this is either the only way or the best way, I just think it may be a more clear example of exists.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

It's not a form, sorry. Your only option is to print it, fill it out, then scan it back in.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Is the PDF form enabled? If they're just lines then you can't do anything, but if they're actual data fields in a form, you should be able to click into and type into them. Whether they're fields or not depends on how the designer of the PDF built it, you don't have any control.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You don't. That's why it's called Adobe Reader. To edit PDF files you need something like Acrobat or LiveCycle, but note that those options aren't free like Reader.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

he got no code guys. use your imarginations. we are gods!

He stated that he's getting errors, this suggests some attempt was made.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

To add to clife's explanantion, #ifndef foo is functionally identical to #if !defined(foo).

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

is there a way to save those printed lines so I can print them again later?

Yes, of course. Store them in an array or other collection rather than print them directly. Since you don't necessarily know the size of the file, I'd suggest a linked list instead of an array. They're easier to grow dynamically.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Could you post a small but complete program that exhibits the problem here? We're not generally keen on downloading things, and it makes it harder to eyeball the code quickly.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I can see how one can make the first letter of each token uppercase from a string, but not when it's being printed from a text file being read.

You're reading from the file into a string.

I'm not sure where else I can properly apply the strtok aside from that and printf().

strtok cannot be used recursively. You can perform some magic by changing the delimiter briefly, but another option is to separate the name a different way. Here's an example (without error handling) using strchr.

#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static const char *employee_type[] = {
    "", "Owner", "Manager", "Grunt"
};

char *format_name(const char *name, char *buf)
{
    const char *sep = strchr(name, '_');

    buf[0] = '\0';
    strncat(buf, name, sep - name);
    buf[0] = toupper(buf[0]);
    strcat(buf, ", ");
    strcat(buf, sep + 1);
    buf[strlen(buf) - strlen(sep + 1)] = toupper(sep[1]);

    return buf;
}

int main(void)
{
    char empno[BUFSIZ];

    fputs("Employee #: ", stdout);
    fflush(stdout);

    if (fgets(empno, sizeof empno, stdin) != NULL) {
        FILE *in = fopen("test.txt", "r");

        empno[strcspn(empno, "\n")] = '\0'; /* Trim the newline */

        if (in == NULL) {
            perror("Error opening file");
            return EXIT_FAILURE;
        }
        else {
            char line[BUFSIZ], name[BUFSIZ];

            while (fgets(line, sizeof line, in) != NULL) {
                line[strcspn(line, "\n")] = '\0'; /* Trim the newline */

                if (strstr(line, empno) != NULL) {
                    printf("Employee #: %s\n", strtok(line, ",") + 3);
                    puts(format_name(strtok(NULL, ","), name));
                    puts(employee_type[atoi(strtok(NULL, ","))]);
                    break;
                }
            }
        }
    }

    return EXIT_SUCCESS;
}

And here's the tricky way to …

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

it gives me errors when i run them

You didn't post any code or any errors. How do you expect someone to help you resolve them?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

int and int* are incompatible types even in C, a cast has been required since the C90 standard.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

give me a link for read more about that magic numbers?

Magic numbers are just that, magic. They're selected completely at the discretion of the programmer, so there's really nothing to document in general about magic numbers beyond. A good library should hide any use of magic numbers from you anyway.

What I've been saying is that you need a very specific case to study, but this case is not a good one because merely using the magic numbers is a bad practice.

Instead, I think you'd be better off studying bit twiddling in general, rather than continuing with this specific usage. Try googling for "bit manipulation exercises".

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

i need to understand them because seems to be used in very situations.

In this case you don't. Someone gave you bad advice.

please give more information about these type of calculations.

First you need to figure out what those magic numbers represent. It's harder because they're intended to be opaque and not worked with directly here. Once you find out what each of the constants you want to work with represent, it's simple enough to figure out what the bit operations do for you using the corresponding truth tables.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

It's fairly straightforward. You already know how to split a line, so it should be a simple matter of splitting using an underscore as the delimiter, making the first letter of each token upper case, then outputing the tokens with a comma in between.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Otherwise, I'm absolutely baffled that no error occured.

It depends on the compiler. Modern compilers should error out if you don't properly cast the literal:

int *ptr = (int*)12;

I wouldn't be surprised if Turbo C allowed it without the cast. However, it's generally a bad idea to set the address of pointer from a literal. The situations where you even can do it successfully are few and far between. Most of the time you'll just get a runtime error.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You'll understand that what I'm saying.

While I understand what you're saying, I disagree. Learning the theory is indeed critical, but experience is equally critical. To gain experience, you need to work with data structures in an actual programming language. C is a good choice because it's low level enough to not hide any of the nuances of the data structure implementation from you and avoid unnecessary boilerplate while also being high level enough to give you a good overall view of the algorithms involved.

The experience gained from C can easily transfer to most of the languages in common use today.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

but why these number and not other?

Magic numbers for bit twiddling are typically chosen to be unique bit patterns. For example, in the case of flags that are intended to be OR'd together you'd typically want to choose numbers where a single bit is set:

0x01 = 0000 0001
0x02 = 0000 0010
0x04 = 0000 0100
0x08 = 0000 1000
0x10 = 0001 0000
0x20 = 0010 0000

That way when they're OR'd together, you get a bit pattern that can easily be tested with AND.

The problem with your question is that you shouldn't be using magic numbers at all. Rather, you should be OR'ing together the manifest constants for those flags, even if it's more verbose. The constants are there because the magic numbers could change, and then code that uses the magic numbers would break.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

And also, as Agilemind pointed out (which you said you misunderstood for some weird reason)

I understand Agilemind perfectly. My difficulty was in phrasing my response. Did I make that unclear?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

So prostate emaninations and treatment for various disorders of same (enlargement, cancer, etc) apply equally to both sexes?

Right now you've got cervical cancer screenings at no cost, for example, but prostate cancer is statistically more pervasive and fatal by orders of magnitude yet screenings aren't covered at all last I checked. Where's the logic there?

I have no problem with things like covered screenings, but isn't it more rational to focus on high risk conditions in general rather than saying what amounts to "women get a free pass, men gotta pay"?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You need to get the console text attributes before changing them, then reset them after you're done (either before or after setting the cursor position).

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Insurance is based on the fact that the majority of insured persons won't use the majority of services they are insured for - they subsidize the unlucky few who do need to use them, otherwise insurance premiums we be no different than paying out of pocket.

I'd be okay with that, if the services subsidized were something I could potentially use if unlucky enough to need them. Try grepping the legislation for instances of "women" and "men". Then cross reference the preferential treatment in each instance. Maternity coverage is merely the most obvious and easily defended of sexisms in the legislation.

Last I checked, there were well over 100 benefits unique to women (that men are required to subsidize, recall). Conversely, male-specific benefits was 0. This is hardly fair, and I question half the population being forced to pay for things they couldn't possibly use (ever!).

And frankly, pregnancy almost always involves two participants one of which may be an unmarried older man. Why shouldn't he contribute to subsidizing the health care costs of the unmarried pregnant woman?

Almost always? More like always, unless science has invented artificial sperm. I'd like to respond to the logic here, but I'm having trouble properly putting it into words. Sorry.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

cin is in the std namespace. If you don't have a using statement somewhere to expose it, you need to qualify the name: std::cin.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

There's not a post limit on threads. Feel free to ask subsequent related questions here. :)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Allow me to ask the obvious question, why would you want to recursively read a file?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

It should already behave this way. However, because the lifetime of the window is tied to the lifetime of your program, you have to keep the window open long enough to see results. For example:

#include <stdio.h>

int main(void)
{
    puts("Hello, world!");

    getchar(); // Pause for input

    return 0;
}

This is for console mode programs, of course. If you want a GUI then it's a smidge more complex. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Your semicolon got loose and climbed the structure definition.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

But why when i try this your solution^^^^, i still keep getting warning:

I always disable that warning, and even though I'm paranoid about disabling warnings, don't hesitate to recommend the practice in this case. 4996 is just Microsoft forcing you to use their non-standard library.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Because your compiler thinks using ctime is such a bad, bad idea that it's not going to let you do it unless you specifially tell it to let you.

Actually, that's just a warning. He (wisely) has warnings set to fire as errors, but in the case of 4996, it's usually spurious. We can debate the merits of the warning in this case, but without more information about the program it's not conclusive.

A better solution, in my opinion, than ctime_s (which isn't widely supported or standard in C++) is strftime.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

But are you saying that it is SO stupid that NOBODY ELSE on this site could possibly make it ever again ? Actually I do hope you are right about that.

That's not what I'm saying. I wish it were true, but I'm not that naive. What I'm saying is that this really has nothing to do with Windows 8 specifically. You could just as easily "warn" people to be careful that when buying an automobile it could run on diesel or gasoline (or electricity, or hybrid, etc...). And you'd just as quickly get sneers that it's common knowledge and you should do research before making a purchase.

Is it okay to mention 32 bit or 64 bit on a list of things to consider when getting a new OS? Absolutely. But I don't think it constitutes a "warning".

how prominent is any writing on the disk and/or its packaging
saying ‘32-bit’ or ’64-bit’ ?

I don't have my packaging handy at the moment, but IIRC it was present and not easily missed.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Note, I am NOT trying to correct this problem here, just warning people what to be careful about.

I fail to see how this warning has anything to do with Windows 8 (or 8.1). As the end user it's your job to specify what you want and verify that you received what you want.

If this is your personal PC, the onus is completely on you. If this is a company PC, as AD mentioned there may be a number of perfectly legitimate reasons why you were given a 32 bit version.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

By the way, can you find out a way to make the program print…

Did you not read my post?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Looks fine to me. Though if you're not required to implement quicksort, I'd recommend simply using merge sort. Merge sort is better suited to linked lists because it doesn't require random access. Quicksort on a linked list is tricky to implement efficiently due to the random access component, especially if you're using a singly linked list.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Will this code work?

No. That could easily be determined by trying to compile it. Let's remove the complication of functions for a moment and consider how to get the result you want. There are two issues:

  1. "EMP" needs to be eliminated from the employee number result.
  2. A numeric identifier for the employee type needs to be converted to a display name.

#1 is simple enough if you're sure that the token matches the pattern correctly, just shift the pointer forward by 3 characters. #2 is slightly more complex, but the core concept is to use the numeric identifier as either an index or key into a collection of display names.

Here's an example. Robust error handling has been omitted for brevity:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static const char *employee_type[] = {
    "", "Owner", "Manager", "Grunt"
};

int main(void)
{
    char empno[BUFSIZ];

    fputs("Employee #: ", stdout);
    fflush(stdout);

    if (fgets(empno, sizeof empno, stdin) != NULL) {
        FILE *in = fopen("test.txt", "r");

        empno[strcspn(empno, "\n")] = '\0'; /* Trim the newline */

        if (in == NULL) {
            perror("Error opening file");
            return EXIT_FAILURE;
        }
        else {
            char line[BUFSIZ];

            while (fgets(line, sizeof line, in) != NULL) {
                line[strcspn(line, "\n")] = '\0'; /* Trim the newline */

                if (strstr(line, empno) != NULL) {
                    printf("Employee #: %s\n", strtok(line, ",") + 3);
                    puts(strtok(NULL, ","));
                    puts(employee_type[atoi(strtok(NULL, ","))]);
                    break;
                }
            }
        }
    }

    return EXIT_SUCCESS;
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

but i still want to know if it can be done

Yup, it can be done. How depends somewhat on how you're deploying the setup.exe, but typically for standalone installers you can either use the default user interface, tweak the default user interface, or define your own completely.

For example, in Visual Studio's Setup & Deployment project (.vdproj), if you right click on the project and choose User Interface from the View menu, you can fiddle with the install wizard views. You can also use custom actions to get a little more flexibility.

With something like WiX, you get much more control over the UI, but at the cost of a steep learning curve for the declarative XML language. I actually prefer WiX if any kind of customization beyond UI banners is needed, otherwise the standard Setup & Deployment project is easier to build and maintain.

InnoSetup is also popular because it has an expressive scripting language. I haven't done much UI customization from InnoSetup though, so I'm not qualified to provide details on your question.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

It sounds like you've got a dependency on .NET that's not available in Mono. Try running MoMA on the assembly to see if there are any issues.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

But does the garbage collector doesn't take care of that?

The garbage collector takes care of memory for objects, but it doesn't know about internal resources allocated by the object. A good example is file handles. The garbage collector will clean up memory for a FileStream object, yet the file handle still needs to be closed.

A class implementation could put all of the cleanup code in the finalizer if there's no problem with waiting until the garbage collector gets around to cleaning up the object. The problem with that is that things like file handles should be disposed of as quickly as possible when you're done with them. That's what the IDisposable pattern is for: deterministic disposal of extraneous resources held by an object.

darkagn commented: Excellent description of garbage collection vs IDisposable +11
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

My only nitpick is a pet peeve in that SpeechSynthesizer implements IDisposable, which one should always respect:

using (var synth = new SpeechSynthesizer())
{
    synth.Speak(message);
}

It's ironic that MSDN's own examples typically don't respect IDisposable, despite the common occurrance of the following note variation on the same documentation page:

"Always call Dispose before you release your last reference to the SpeechSynthesizer. Otherwise, the resources it is using will not be freed until the garbage collector calls the SpeechSynthesizer object's Finalize method."

Then again, MSDN historically hasn't been a provider of good example code. ;)

ddanbe commented: Good remark! +15
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Please specify what you mean by "help". Because what you've posted so far suggests you want someone to do work for you, which isn't what Daniweb does.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

i have read so many places that reference is const pointer.

Not so much. While it may help to think of references as constant pointers where indirection is done for you, eventually that relation will fall short. Here are a couple of notable differences:

  • A const pointer can be a null pointer while there's no such thing as a null reference.
  • A pointer has a unique address. A reference has the same address as the referenced object.
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

If this professor worked for me, I'd fire him!

I'm okay with these examples as thought experiments, provided it's very clearly stated that this is not how you should write code, and by working through the examples you can see why.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

These examples are hideous. But let's break it down.

(((i+=3)&&(i++>6))||((++i>8)&&(i+=3))

i starts as 3. Then it's immediately incremented by 3 (making it 6) and tested against 0. 6 is not equal to 0, so the first half of the && clause succeeds. i is not greater than 6 so the second half fails, but i still gets incremented to 7 afterward as the postfix increment is used.

Both sides of the || are tested because one might be true, so i is then incremented before testing the left clause of the right hand &&. This fails because i is now 8, and the test is asking if i is greater than 8. This is an && test, so the right hand clause doesn't need to be checked if the left hand clause fails, so i is not incremented further by 3.

Both && statements failed, and i remains 8, so your output is the body of the else clause.

for(i=0;i++<5;) a[i] = i*10;
for(--i;--i>0;)
    printf("%d - %d \n",i,a[i]);

This one is relatively easy. In the first loop i is always incremented, but only after testing against 5.

The end result is that a[0] is never modified, but a[1] through a[4] are. At the end of the loop, i is 6, so the second loop decrements it immediately to 5. Then the condition decrements it again before testing against 0. The result is that you have a perfect reversal of the first loop.

printmax((i++),(j++));

This …

ddanbe commented: weird examples, but helpfull explanations +15
rubberman commented: Helpful, but these are TERRIBLE examples of C code. Why not try to teach proper coding practices! :rolleyes: +12
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

i ment to put c i just changed it to counter so you guys knew what it was

That's a hint that it should be counter in the first place rather than c.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Yes a visual calendar similar to outlook is exactly what I am looking for but cannot find any information on the internet.

Have you tried...you know, being creative and stuff? The internet won't tell you how to solve every problem.

Ketsuekiame commented: +1 for creativity. Seems to be a long forgotten/forbidden art... +9
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

That's an issue with your code editor. If you can set the character set to something like Unicode, you should be good to go.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The version of gcc matters here because you may not have a version that supports member initialization from C++11. Also, are you using the -std=c++11 or -std=c++0x when compiling?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

What compiler and version are you using?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The good news is you can do it. The bad news is you have little choice but to use a platform dependent method to set the console into a wide character mode. For example:

#include <iostream>
#include <fcntl.h>
#include <io.h>

using namespace std;

int main()
{
    _setmode(_fileno(stdout), _O_U16TEXT);

    wcout << L"glória vitória\n";
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Why not use a DateTimePicker control, instead of your scheme of dates and times?

It seems like he wants something more like a visual calendar (similar to Outlook). A DateTimePicker might be part of that, but not sufficient for the whole solution.