deceptikon 1,790 Code Sniper Team Colleague Featured Poster

But its case sensitive and i want to search case insensitive word. Can someone guide me plz?

When you want a character comparison that's case insensitive, you can convert both characters to either upper or lower case. For example:

#include <cctype> // For toupper/tolower

...

if (tolower(str[i]) == tolower(find[0]))

The reason this works is tolower() will simply return the argument if there's no lower case conversion, so you'll either get the lower case variant of the character if one exists, or the character itself if no such conversion exists.

If you end up using a library to do the comparison then it gets a bit trickier because some libraries (such as strcmp()) don't support any way of enabling a case insensitive comparison. But that's not currently relevant because you're doing the comparison manually. :)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Here's a C++ program:

#include <iostream>

int main()
{
    std::cout<<"Hello, world!\n";
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The quality of your speakers will affect the sound, obviously. In my experience, any speakers built into a monitor are best disabled as they suck many asses.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Oh the shattered hopes and dreams... :)

I'm pretty sure it's in my Daniweb contract somewhere that I have to crush dreams on a regular basis.

<M/> commented: Hahaha :) +0
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

@deceptikon, please update or allow Michael to upload an animated pic. anything to swap out that horrendous avatar that he currently has that looks like a cross between a Chihuahua and an an Ostrich. lol...

Haha! But seriously...you think that thing would be better animated? O_o

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

here is the problem

Open a debugger and step through your code. I've done this and see what your problem is, but I won't always be around to hold your hand. So I want you to debug the code and see it for yourself. This is something you'll be doing a lot as a programmer. For every hour you spend writing code, you'll spend five hours debugging it.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I'm trying to imagine something more direct than a request from a client and a response from a server

VPN into the server and access its file system like you would any computer on a local network. That's what I mean by "direct". If that's not what you were thinking of, then I'm curious how you're imagining a data structure that's shared between server and clients yet is somehow revolutionary or different from the usual request-response designs.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I am learning C++ on Turbo C++ 3.0

That's a very old compiler, and it's going to hold you back significantly. Unless you're forced to use it for some reason, I'd strongly recommend upgrading to something like Code::Blocks or Visual C++ Express.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

RESULT OF INFIX : -48

Use a debugger and step through your code. Make sure that each line does what you think it does with the given input.

Pro Tip: The result always seems to be -48, and that's important to notice.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

And what happens if the original image is 80x80? You still resize it?

A resize is always attempted, regardless of the original dimensions. Honestly, I haven't tested whether an 80x80 animated image flows through (ie. the imaging library treats it as a no-op), or if the resize still behaves the same way regardless of original dimensions. What you suggested may be a workaround.

If yes, you folks are bad guys. ;)

How so? ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

There's nothing wrong with your code, but use of <iostream.h> suggests an old compiler that may not respect the standard language. What compiler are you using?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Compare and contrast:

void stack::result(stack &post)
{
    int i;
    int a,b,c;
    char oper;
    int res=0;
    for(i=0;i<=post.topnum;i++)
    {
        if(post.data[i]=='+'||post.data[i]=='-'||post.data[i]=='*'||post.data[i]=='/')
        {
            pop(oper);
            a=oper-'0';
            pop(oper);
            b=oper-'0';

            if (post.data[i]=='+')
                c=a+b;
            else if (post.data[i]=='-')
                c=a-b;
            else if (post.data[i]=='*')
                c=a*b;
            else
                c=a/b;

            oper=c+'0';
            push(oper);
        }
        else
        {
            push(post.data[i]);
        }

    }
    pop(oper);
    res=oper-'0';
    cout<<res<<endl;
}

Also take note that you'll have issues when the numbers reach more than a single digit. I'd personally also make result() a non-member function and create a local stack for the evaluation. The way you have it is unintuitive.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

There also it should display one linker error since we have defined static variable inside .h file

Different things, different mechanics. You would get a redefinition error concerning the class if you included file.h twice either directly or indirectly, but that has more to do with the class than the static const member. Note that my example file.h has inclusion guards to protect against that particular problem by only including the header one time per translation unit.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Your call to mysql_query() failed and returned FALSE. Use mysql_error() to get details as to why the query failed.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

:(
this is the output
after i but ur code

The postfix is correct. The result is obviously not correct, but that's not relevant to the problem you stated of a more complex infix equation being converted incorrectly.

Anyway, I'm not telling you where the exact problem you're having is, I simply eyeballed the code and pointed out a very obvious bug. If fixing that bug doesn't fix the problem then the problem is rooted more deeply in your algorithm.

Please don't expect me to do your thinking for you.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I know the header files are never compiled.

Header files are always compiled if you include them. The problem is that you have an object definition in a header file, which means that by including it more than once you've violated the one definition rule. Inside the header you should be using the extern keyword:

// file.h
#ifndef FILE_H
#define FILE_H

extern int GlobalVar; // Declaration only

class File
{
public:
    static const int var = 9;
};

#endif

Then ideally you would have an implementation file for the header that handles the one definition:

// file.cpp
#include "file.h"

int GlobalVar = 0; // Definition

Compile and link file.cpp as normal, include file.h wherever you want, and all will be well using this design.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

still error....

...so you wrote a member function that goes around your ass to get to your elbow and do exactly the same thing as just accessing topnum directly? What I meant was write a member function that returns the top value on the stack; a pop without the pop:

int top_value() const
{
    if (isempty())
        throw "Stack is empty";

    return data[top];
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Equal ages to what? Do you want groups of employees where each group has the same age? Do you want all employees matching a specified age? You can't write a query with vague terms.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

how to solve it ?

Provide a public member function that returns the top of the stack without popping it.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

"System" is pretty vague. Have your studies focused on anything in particular? Do you have any interests that might suggest a possible project?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Start by writing a function that will replace words in a string and use a small program to test it in the absence of user input. Your program can be broken down into smaller subproblems that are easier to solve and less overwhelming.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

At a glance, the following line is wrong:

if(op.topnum=='*'||op.topnum=='/')

topnum will never likely be either '*' or '/', it's a public alias for top, which is an index rather than a value. Unless the expression is rather large, this condition will never evaluate to true.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

thnx guys.those two comments made my confusions clear.that is all i wanted to know.

Cool. Actually, I think the function call entry sequence point is the most difficult of them to wrap your head around because often it's academic in nature and makes no apparent difference in practice.

All of the other sequence points are pretty straightforward, with the possible exception of the comma operator because not every use of a comma in C is the comma operator (what kind of existential mess is that?).

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I am using C. I've included stdbool.h, its in the "includes.h" file.

Booya. It's nice to see someone taking advantage of more recent revisions of the C standard.

but I dont understand why main.c is accepting the existance of toMakeFood and timer0.c is not.

That's simply where the lack of a definition is reported. If you remove timer0.c entirely from the project then you'll still get the error because toMakeFood really doesn't exist. You've only provided a name and a type in includes.h, not an actual object that can be worked with.

And the reason why you shouldn't have a definition in includes.h is because then there would be multiple definitions of an object with the same name, which would still result in a linker error. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

anyone?

You've had two whole days to work on this program, what have you come up with? Daniweb has a homework rule that states you must provide some proof of effort. If you've just been sitting on your butt waiting for a kind soul to give you everything then you deserve a failing grade.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Even now as I type this I am reading your post because my browser accessed it as data from a web server.

Your browser made a structured request and the server sent you the data. The client (your browser) didn't access the data directly. That's the difference from my reading of your first post. You seem to want clients that actually hit the server and fetch data directly rather than sending a request and having the server fetch it.

FTP servers also come to mind as clear examples of clients accessing data on a server.

FTP is a structured protocol for making a data request. Once again, the client doesn't go and get the data directly, regardless of how it might seem with some FTP interfaces. It makes a request for data which the server then responds to by fetching the data and sending it.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Is there a way to change your avatar into an animated avatar?

No. When you upload an avatar, we resize it internally to ensure that it's 80x80, and the method we use to do that only returns the first frame of an animated image.

I have seen a few avatars that are animated... Know how to upload one?

Most likely you've seen avatars that were grandfathered in during the migration from vBulletin to the current system. That would have side steped our upload process, but it doesn't help you now because the only way to get an animated avatar if you didn't already have one would be to edit the database manually.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

toMakeFood doesn't exist because everywhere you have a declaration of it, you're saying "defined elsewhere" due to the extern keyword. Add an includes.c file with this:

bool toMakeFood = false;

And don't forget to link that file in with the rest. The header will provide multiple delcarations while the .c file will provide a single definition. On a side note, I strongly suspect you're compiling as C because bool and true/false require the inclusion of the stdbool.h header.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Yeah I respect their decision

That's irrelevant. The idea is to make sure that they know you respect it so as to avoid burning bridges. Why? Because you're basically questioning their ability to run your code by suggesting that it's correct when they say it's not.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

This:

strncpy(p->name[(p->count)++], q, 20);

Is roughly equivalent to this:

strncpy(p->name[p->count], q, 20);
++p->count;

I'm not sure where your confusion lies, but I'm all but certain you're overcomplicating things.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I'd mention that the code works on my end and ask how they're testing it on their side. Make it clear that you respect their decision to halt the interview process and that you're most interested in learning what you may have done wrong.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Such a list would be subjective no matter how you look at it because everyone has different goals and problems that need solving. A better approach is to consider each problem you have when you have it and then ask if there's a function out there that already does it. You don't need to fill your head with every available function; simply using the language and building a list of your most useful functions over time is just fine.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The compiler is right. You declare copies without initializing it, then immediately try to print its value. That's undefined behavior, and constitutes a bug.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Good luck with that. I hope you realize that you failed to provide enough information for anyone to help you.

Begginnerdev commented: That too! lol +6
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

My boss likes to do that. Write the simple structure of code and then litter the hard parts with TODO comments for me to fill in. :rolleyes: It also doesn't help that we have wildly different opinions about simplicity and how code should be structured.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Actually i am very new to programming and thus finding this a bit difficult.

All the more reason to practice. Though if you have any specific questions I'm happy to assist.

p.s. It doesn't get any easier, you just replace simple problems with more complex problems. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

But how do i get the resulting solution to a new file ?

Open a second FILE* that writes to a file and use it in place of stdout. Do you know about file I/O in C?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

isn't there supposed to be another file on which the new content is to written ?

I don't know, is there? My code was an example. If you want to modify it or use it as a template for a more specific solution to your problem, then do so. I actually have plenty of my own work to do, and I'm disinclined to add your work to that pile.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

could u can plzzz,,,,,,,,,,,......

No. Do your own damn homework, and if you have a specific question or difficulty that doesn't amount to "I'm lazy, gimme gimme gimme", we'll be happy to assist.

NathanOliver commented: I guess it is to hard to read the rules +10
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You're focusing too much on the little things and not seeing the big picture. The problem is very simple: display any line where the first non-whitespace character is a digit. To do that you read each line in turn, find the first non-whitespace character, and print it if it's a digit. Easy peasy:

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

#define WHITESPACE " \t\n\r\f\v"

int main(void)
{
    FILE *in = fopen("test.txt", "r");

    if (in) {
        char line[BUFSIZ];

        while (fgets(line, sizeof line, in)) {
            char *first = line + strspn(line, WHITESPACE);

            if (isdigit(*first))
                fputs(line, stdout);
        }

        fclose(in);
    }

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

What have you done so far? If you haven't written any code, what thoughts have you come up for solving the problem? Did you test any ideas with a small test program?

If you haven't done anything, why not? Keep in mind that nobody here will do your homework for you.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I don't know what to properly call a system like that, but on the surface it seems like a simple problem.

I'd call such a system "stupid". If the client needs to make changes to or retrieve data on the server side, it should send a request to the server and the server should make those changes or push the requested data. A client with access to data on the server side, on top of being awkward and counterintuitive given the concept of a client-server setup, would be extremely brittle by nature.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I don't know of any IDE's that exist on them.

There are IDEs, editors, and compilers that run on a tablet...but they all suck. However, it doesn't strike me as unreasonable to use something like Ideone to write and compile code, then copy/paste it into a post all on a tablet. Awkward, yes, but not so awkward as to be completely prohibitive.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Well you can forget about the pronunciation. The most important is that you can see what they are doing.

Watch a video tutorial with the sound off and see how useful it is. ;) Honestly, if that works out then the video didn't need to be a video in the first place.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Modify the Downdog Yoga Studio program

This suggests that you have pseudocode from a previous exercise and the current exercise is an extension of it.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

i would like to enter 6 random objects on this grid that the arrow can pick up where would i enter the random number generator to put them on the grid?

I'd put them in SetupScreen(). Once you're done filling the grid with dots, randomly generate six different coordinates and populate them with something other than a dot:

void SetupScreen()
{
    for(int height = 0; height < MAX_HEIGHT; height++) {
        for(int width = 0; width < MAX_WIDTH; width++) {
            Screen[height][width] = '.'; //Initialize each grid position
        }
    }

    Screen[xPos][yPos] = '<'; //Set the users initial cursor position

    for(int n = 0; n < 6; ) {
        int x = rand() % MAX_HEIGHT;
        int y = rand() % MAX_WIDTH;

        if (Screen[x][y] == '.') {
            Screen[x][y] = '*';
            ++n;
        }
    }
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I dont use memcpy often

As well you shouldn't. memcpy() is a very low level function that was inherited from C. The problem with memcpy() in C++ is that it doesn't respect class structure or construction/destruction, so unless you have what is called a POD type, use of memcpy() is undefined. My usual recommendation is to forget memcpy() exists unless your code is C compatible.

The usual shallow copying problems present in C were also inherited, such that if you copy a pointer, only the address gets copied and not whatever the pointer points to. That results in an alias that, when unintended, wreaks havoc on memory.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

having trouble finding this anywhere, on a 32bit computer, how many bytes does it take to store ; long int, unsigned char,float, double

You're having trouble finding it because there's no absolute answer. Only char has a guaranteed size (it's always going to be 1), the rest are implementation dependent (though nullptr listed common sizes on a 32-bit implementation).

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The standard for c++ says that main must look like one of these three options.

Or equivalent, to account for different names and things like typedef. The following is still strictly conforming:

typedef int foo;
typedef char *bar;

foo main(foo shizzle, bar *nizzle);

The C-style way of defining main with an explicit void parameter is also allowed and equivalent to the empty parameter list:

int main(void);
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

t=t;

This accomplishes a whole lot of nothing. All you're doing is simulating the effect of strlen() without the overhead of a function call, so no assignments are necessary. Just bump the value of t until it's pointing to a null character:

while (*t)
    ++t;

You also don't use j, but presumably the idea was to provide a limit if the source would overflow the destination. In that case you'd be duplicating the functionality of strncat():

char *xstrcat(char *dst, const char *src, size_t n)
{
    char *p = dst;

    while (*p)
        ++p;

    while (n-- && *src)
        *p++ = *src++;

    *p = '\0';

    return dst;
}

Though it's also possible you intended to use it as a starting position instead of calculating it internally:

char *xstrcat(char *dst, const char *src, size_t pos)
{
    char *p = dst + pos;

    while (*p++ = *src++)
        ;

    return dst;
}

I'll let someone else browbeat you for using void main, but I'll mention that your variable names are too concise to make for readable code. t, s, and j are all pretty much meaningless; single character variables should be reserved for the most common of uses. Included in that list might be:

  • i: Loop counter/array index
  • j: Nested loop counter/array index
  • k: Deeply nested loop counter/array index
  • m: Table row index
  • n: Table column index, total count of items, or array size
  • s: General string
  • a: Left hand side operand
  • b: Right hand side operand