WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Good idea jonsca

Salem commented: Score! +19
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

check this code

OK...

#include<stdio.h>
# include <stdlib.h>
int main()
{
    int x = 0;
	printf("plz enter a number : ");

Improper English. It's spelled "Please"

scanf("%d",&x);
	
	int y = 2 , z = 0;
	int * factors = (int*)malloc(100 * sizeof(int));

Declaring variables after executable statements is illegal in Standard C -- at least with most C compilers in use.

while (x != 1)
	{
		if (x % y == 0)
		{
			x = x /y;
			factors[z] = y;
			z++;
		}
		else y++;
	}
	z--;
	int a = 0;
	while (a <= z)
	{
		printf("%d ",factors[a]);
		a++;
	}
	
    return 0;
}

Finally, what does finding the factors of a number have to do with the factorial of a number?


Other than that, it is nicely formatted. Unfortunately, you attempted to do his homework for him. We don't do that here. We help them write their own code.

Nick Evan commented: Nice one :) +12
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Depends on what you're trying to do. With all the '#' signs and no formatting, the code is too hard to follow without some explanation. Plus you should always explain what you're doing and not force us to read, understand, digest, and debug your code. Remember, we didn't write it so we don't know it.

And use the PREVIEW button to make sure your post looks good.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You have to pick one of your threads, don't just keep adding to both.

sorry.... was a mistake... reply here... or there... anywhere is fine.....

No it isn't. "Anywhere is fine" doesn't solve the problem.

Other thread closed. Problem now solved.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

No, what the problem is your understanding of numbers.

10.1 is identical to 10.10 is identical to 10.1000000
Each is 10 and 1 tenth. It doesn't matter how many zeros you add.

Therefore, 10.5 (10 and 5 tenths) > 10.10000000

Salem commented: :) +19
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

When they pass in the list address to delete, if it hasn't been initialized, don't delete it. Return an error code.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

With what? You gave us nothing to help with. Did you forget to read the Rules and the sticky posts at the beginning of the forum?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I just realize you have it static. Of course it wouldn't work.

You do not want your variable to be [B]static[/B] .

Your code:

static int lowest_num;
  static int  next_num;

Do you listen this well in class too?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

My password is always the day of the week my password was created. I tell people that, too, because it's not like they'll know what day of the week I created it. That makes it secure. Extremely secure.

Really? Give me 7 guesses... :icon_rolleyes:

Nick Evan commented: hehe +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

no i'm not callin main anywhere...

Guess my psychic powers were on the fritz....

Please consider reading the Rules and Sticky posts that describe how to ask for help. For one, CODE tags are described
1) in the Rules you were asked to read when you registered
2) in the text at the top of this forum
3) in the announcement at the top of this forum titled Please use BB Code and Inlinecode tags
4) in the sticky post above titled Read Me: Read This Before Posting
5) any place CODE tags were used, even in responses to your posts
6) Even on the background of the box you actually typed your message in!
so you can't miss them -- only ignore them.

And posting almost 400 lines of code and expecting us to try to figure out
1) What you're trying to do
2) What is wrong
3) Where it's wrong
4) How to fix it
just is not appropriate. Help us. Try to pinpoint where it's wrong, it's your job to give us enough details to understand the problem.


[edit]

hey i'm sorry tat i've to leave now.....
so please look over my code and reply me where have i made a mistake...
will reply u later..

Ahhh, another "here, you fix it for me while I go do something else" request. Figures.

Salem commented: Well said +19
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

gerard, please don't fix people's code for them with no explanation. They learn nothing.

solitude_spark, the problem is you specified #include <file1.h> . The <brackets> tell the compiler to look in the compiler and system directories but not in the current directory. To search in the current dir use "double quotes" #include "file1.h" .

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Set up another array of 16 (say ptr ) with values from 0-15, randomize that array. Then you access the dice array:

r = random value (0-15)
dice[ptr[r]][x]
rkulp commented: Thanks for the help, it was exactly what I needed to know. +1
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Does the motive for starting a thread make a difference to the help that should be offered? I'm a hobbyist, so any help passed in my direction will not make me any money or help me pass any examinations.

No, your motive should not be a factor -- unless the motive is for someone else to write the program for you. Whether a student, hobbyist, or professional, IMO you should ask an appropriate question, and give enough detail so someone can point you in the proper direction. We are not a coding service, and it bothers me when someone hands out code willy-nilly. If you are asking a question, you are willing to learn. If you aren't willing to learn, there are a lot of other sites where you can have someone write your code for you -- for a price (and there should be a price).

Am I (attempts at solving the problem myself aside) more or less deserving of help than somebody with a critical interest (e.g. somebody in the IT business or a student)? Is this even relevant - should help be provided piecemeal (even cryptically) regardless of the motive?

Irrelevant.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Somebody forgot to read the Forum Rules as requested multiple times upon signing up.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

"To be is to do"-Socrates

"To do is to be"-Jean-Paul Sartre

"Do Be Do Be Do"-Frank Sinatra;

Salem commented: yaba daba doo - Fred Flintstone :) +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I have a problem with this topic ..Solution to algorithm using static and dynamic data structure

I have a problem with this topic too. There is no solution to the stated problem.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Perhaps 20% of new users in the php forum. However they/dani missed a spot. When you reply to a 4 year old topic and your not signed in I don't think there is the code tags message in the textbox. So yea that is where the problem with the code tags lies.

a) I'm more familiar with C/C++. and it's more like 80-90%.
b) You cannot post without being signed in. Try it.
c) I just looked at the very first post in the PHP section. The Code tag message is in the text box.

[pedantic]
And
-- your is possessive -- it's your problem.
-- you're is the contraction of you are
FYI :icon_wink:
[/pedantic]

iamthwee commented: Genius! +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Ummmmm, OK, I'm really missing something....... How do I post on Daniweb??????

I would guess exactly as you did here.

iamthwee commented: LOL +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Another suggestion: format your code better. Indents are too deep and not consistent.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Please mark as solved.

Why? The title "Thoughts on Google Chrome..? " is an invite for discussion. One person saying "try this instead" is IMO not a discussion... :icon_wink:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

As for your problem, where does the player start from ? I don't see
a way to get in the maze from outside, so I figure there is a starting point.

I think there must be a start position too!

Ummm, guys, read the post:

The program is run with command line arguments, e.g. maze.exe maze.txt 1 1
where maze.exe is the compiled program, [doh!!!]
maze.txt is where the maze is saved(same directory as maze.exe)
1 and 1 are the start coordinates(must be a p)

tux4life commented: Exactly. +6
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

IMO, better code would be:

#include <stdio.h>
void foo(void)
{
   int i = 1;
   while ( i )   // or while ( i != 0)
   {
      printf("\n1: Stack1\n2: Stack2\n0: to return\n");
      scanf("%d",&i);
      switch ( i )
      {
      case 1:
         printf("1");
         break;

      case 2:
         printf(" 2");
         break;
      case 0:
         printf("Thank you for using the service");
         break;
      default:
         printf("Give a Valid Option");
         break;
      }
   }
   return;
}

This leaves one exit of the function -- at the end. I feel it's cleaner, but that's just me...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

How do I do that?

Let me count the ways:
1) in the Rules you were asked to read when you registered
2) in the text at the top of this forum
3) in the announcement at the top of this forum titled Please use BB Code and Inlinecode tags
4) in the sticky post above titled Read Me: Read This Before Posting
5) any place CODE tags were used, even in responses to your posts
6) Even on the background of the box you actually typed your message in!

Does this help?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

We aren't psychic. You need to show us what you tried so we can help you fix it. Did you read the forum rules? Did you read any of the sticky posts at the top of the forum?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

When you test each character do you really want to use i to save the result?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Run this program:

#include <stdio.h>
#include <string.h>
#define NEXTCOL 38

char *strs      = "ABCDEF";
char *strl      = "ABCDEFGHIJKL";
int   sizesingle= 9;
int   size[][2]= {   3,  3,   -3,  3,    3,  9,   -3,  9,
                     3, -3,    3, -9,   -3, -3,   -3, -9,
                     3, 15,    3,-15,   -3, 15,   -3,-15,
                     0,  0,
                     9,  3,   -9,  3,   -9,  9,   -9, -3,
                    -9, -9,   -9, 15,   -9, -15,   9,  9,
                     9, -9,    9, -3,    9,  15,   9,-15,
                     0,  0,
                    15,  3,   15,  9,   15, -3,   15, -9,
                    15, 15,   15,-15,  -15,  3,  -15,  9,
                   -15, -9,  -15, 15,  -15,-15,  -15, -3,
                    -1,  0
                  };
char buf[20];
                
int main()
{
    int  i = 0;
    int  j;
    
    j = printf("  Short -- %d chars <%s> ", strlen(strs), strs);
    while (j++ < NEXTCOL)  putchar(' ');
    printf("  Long -- %d chars <%s>  \n", strlen(strl), strl);
    printf("\n");
    
    j = sprintf(buf,"%*s", sizesingle, strs);
    j = printf("       %%%3ds (%2d)  <%s> ", sizesingle, j, buf);
    while (j++ < NEXTCOL)  putchar(' ');
    j = sprintf(buf,"%*s", sizesingle, strl);
    j = printf("       %%%3ds (%2d)  <%s> ", sizesingle, j, buf);
    printf("\n");
    
    j = sprintf(buf,"%*s", -sizesingle, strs);
    j = printf("       %%%3ds (%2d)  <%s> ", -sizesingle, j, buf);
    while (j++ < NEXTCOL)  putchar(' ');
    j = sprintf(buf,"%*s", -sizesingle, strl);
    j = printf("       %%%3ds (%2d)  <%s> ", -sizesingle, j, buf);
    printf("\n");
    
    j = sprintf(buf,"%.*s", sizesingle, strs);
    j = printf("       %%.%2ds (%2d)  <%s> ", sizesingle, j, buf);
    while (j++ < NEXTCOL)  putchar(' ');
    j = sprintf(buf,"%.*s", sizesingle, strl);
    j = printf("       %%.%2ds (%2d)  <%s> ", sizesingle, j, buf);
    printf("\n");
    
    j = …
Gaiety commented: Fantastic Answer +1
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

To compare a character value, use the character. Single quotes around a single character is what you need: if (chr == 'y') And remember, 'Y' and 'y' are not the same values...

For comparison, double quotes go around a string (or multiple characters): "This is a string"

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

when I deal with clipboard, I have to use GlobalAlloc.

That makes sense. new allocates within the realm of the program. Once the program exits, the memory is released. The clipboard then cleared (or broken). GlobalAlloc , I assume, leaves the allocated memory until the system clears it.

is it recommended to use GobalAlloc where new can be used without problem (in Windows programming)?

No.

CppBuilder2006 commented: convincing +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

> Convert the 20 into decimal, then use math to convert to hex characters. How does 20 become 0x01 0x04?
20 decimal is 0x14 in hex.

I understood. It was a Q to the OP -- wondering if he understood.

Salem commented: okies :) +18
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

OK. then you need the hex value 0x1A, decimal value 26, but not 'Ctrl+Z'

DarkC0de commented: thanks +1
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
Salem commented: Heh, and it wasn't rm *.c - lol +18
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

For first participation, you obviously ignored the request to read the forum rules, and completely ignored all the sticky posts at the top of the forum.

We can't help you with the information you gave.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I search modul for to studying c++ code ???
plase...help me...

You should read the Forum Rules to learn how to post a useful question.

"Plase"...do it...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Just make everything public then you don't need to!

Please reread Narue's response -- carefully -- and you will see why this is a bad suggestion.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Every time you type a character in at scanf("%c",); , do you hit an ENTER? Where does that second character go? It gets read with the next scanf() . See this series about why you should not use scanf() for character & string input. Use fgets() instead.

And in your case, you can define a string instead of a single character, use fgets() to read the input (which automatically clears the input buffer -- within reason), and simply look at the first character in the string for your character. Yes, it's a little kludgy, but that's the problem with keyboard input in C unfortunately.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Never use scanf() to read a string (here's why). In your code, if you enter more than 5 characters you are overwriting memory you shouldn't touch.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

>What is the significance of the following format specifiers:
Relatively low, but they come in handy occasionally.

:twisted: :twisted:

%10s    - Output a minimum of 10 chars, leading spaces
%.10s   - Output up to 10 characters
%-10s   - Output a minimum of 10 chars, trailing spaces
%.15s   - see above
%-15s   - see above
%15.10s  - output up to 10 chars with 5 leading spaces
%-15.10s - output up to 10 chars with 5 trailing spaces

You could have tested it out yourself, you know. Just write a program that tests them:

#include <stdio.h>
#include <string.h>
#define NEXTCOL 38

char *strs      = "ABCDEF";
char *strl      = "ABCDEFGHIJKL";
int   sizesingle= 9;
int   size[][2]= {   3,  3,   -3,  3,    3,  9,   -3,  9,
                     3, -3,    3, -9,   -3, -3,   -3, -9,
                     3, 15,    3,-15,   -3, 15,   -3,-15,
                     0,  0,
                     9,  3,   -9,  3,   -9,  9,   -9, -3,
                    -9, -9,   -9, 15,   -9, -15,   9,  9,
                     9, -9,    9, -3,    9,  15,   9,-15,
                     0,  0,
                    15,  3,   15,  9,   15, -3,   15, -9,
                    15, 15,   15,-15,  -15,  3,  -15,  9,
                   -15, -9,  -15, 15,  -15,-15,  -15, -3,
                    -1,  0
                  };
char buf[20];
                
int main()
{
    int  i = 0;
    int  j;
    
    j = printf("  Short -- %d chars <%s> ", strlen(strs), strs);
    while (j++ < NEXTCOL)  putchar(' ');
    printf("  Long -- %d chars <%s>  \n", strlen(strl), strl);
    printf("\n");
    
    j = sprintf(buf,"%*s", sizesingle, strs);
    j = printf("       %%%3ds (%2d)  <%s> ", sizesingle, j, buf);
    while (j++ < NEXTCOL)  putchar(' ');
    j …
Salem commented: Nice +17
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You need a book on databases. Teaching that is beyond the scope of this forum.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Open your compiler's IDE
Type the code in you've written
Save the code
Run it and see if it works.

iamthwee commented: Wonderful advice, bravo! +11
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

i will give you my code:
and try to adopt it on your code

...
void clear_kb(void)
{ char junk[80];
   gets(junk);
}

You should really read the thread you are posting in. You would have learned something about gets()

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I disagree.

1) I don't like the new buttons. They have a retro feel and don't really do it for me. The yellow buttons fit the look of the page IMO.

2) I prefer multiquote rather than Flag to Quote. The former tells me what the button does. The latter tells me very little.

3) I want the Reply without quote back. I for one use it a lot.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Also you are not writing C++ code so all your variable definitions need to be at the top of your functions, before any executable statements.

And for us to follow your code, use proper formatting

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

how can we use a printf statement without a semicolon???
this was a question asked during an interview of a computer engineering student.

Assuming this was a job interview, I suggest you stay away from any job that asks foolish questions like this. I would not want to work for a company that want it's programmers to use tricks that make code unreadable.

yellowSnow commented: First sensible response to this thread. Exactly what I wanted to say. ;-) +2
kvprajapati commented: Very good suggestion. +6
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

If you want to know how a program works, plzzzzzzzzzzzz post a program. Or try reading the Rules for the site.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I do. And nothing is EVER urgent here. Read the Rules, please.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

OK, so if I want to simply give one single rep point, click the up button, as I did to jbennett above.

Or add your entire rep allotment by clicking the add link, as I did for kaninelupus. But the number is not modified.

And I agree the buttons are very cluttery as well as the bold number.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You need to format your code before posting...

No idea what you are asking. Distinct prime factors? Of what? Show us an example...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

But it does say that people that have clout like what you say... :icon_wink:

jasimp commented: True +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

... DaniWeb is skewed towards a more tech saavy audience.

Why would tech savvy be equated with higher than 1024x768? Don't tech savvy users use laptops? Aren't there a few tech savvy users older and need glasses?

I'm with AD on this one. I personally use windowing, which to me means multiple windows opened at any one time, and I very rarely (maybe 0.5%) ever have any window open full screen. My standard window size for web browsing is about 2/3 of my screen setting, making the main nav bar end at the word BUSINESS. I'm always scrolling to see the 'community guy'. And I consider myself fairly tech savvy.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

OK ...

Thread preview now works for code snippets, so you can see exactly what the formatting will look like before you post. Everyone who submits a code snippet should always preview it first!

Maybe only the PREVIEW button should be available during initial composition. Then SUBMIT can be available only from a PREVIEWed screen. Just a thought.

Dani commented: I was actually thinking that myself. +0
majestic0110 commented: Jolly good idea if you ask me! +0