Adak 419 Nearly a Posting Virtuoso

What'cha wan' a password cracker program for? ;)

You've seen a whole program showing how they can work, and yet here you are, with not *ONE* single line of code posted, showing any understanding or work toward that goal.

Adak 419 Nearly a Posting Virtuoso

The answer to the problem is to use minimax to select the best sequence (or alpha-beta if you prefer), and depth first search. Then you can find absolutely the best picking sequence, for any arrangement of fruit and heights.

Dynamic, shallow algorithms will generally approximate, but can't give, the best sequence, all the time.

Adak 419 Nearly a Posting Virtuoso

Hi friends,


can any one let me know what hash algorithm is used by linux system for its shadow passwords. I'm totally confused some say MD5 and some SHA-512 which one is true and can give the source for answer if got them.

Thanks

linux learner

Only older kernels that haven't been updated would have MD5, now. MD5 encryption was found to be weak when collision analysis was applied.

Before saying anything definitive about their current encryption method, you should check with the homepage of the version of Linux you are interested in. I don't know of any list of the distro's, and what encryption each one is using.

jephthah commented: "me too" -1
Adak 419 Nearly a Posting Virtuoso

Welcome to the forum, papia maity. We don't write programs for people. We help people correct their own code.

If you have some code you're having a problem with, please post it up in a new thread so it will get the attention it deserves.

It won't be favorably seen being posted in someone else's thread.

Adak 419 Nearly a Posting Virtuoso

You haven't given enough information to solve the problem, yet.

Adak 419 Nearly a Posting Virtuoso

I'm not much of a card player, but I think it's helpful if you arrange your suits according to their rank, if the cards face values, ever tie:

Diamonds, then Hearts, then Clubs, then Spades.

I believe that's right.

I'm going to butt out here, I guess. When I see stuff like this, I know you're either quite the genius, or quite mad:

suitIndex = rand() % 4;
	faceIndex = rand() %13;
	
	while( deck[suitIndex][faceIndex] == TAKEN ){
		suitIndex = rand() % 4;
		faceIndex = rand() %13;
       }

Good luck!

Adak 419 Nearly a Posting Virtuoso

Take all the way too many cooks, out of the kitchen -- they're spoiling the meal.

Make a struct for each card:

struct card {
  int value;
  char name[20];
  char suit[10];
  char icon; //3,4,5,or 6 in ASCII chart
  int dealt;
  //etc.
}card1;

int main() {
  struct card cards[52];

There's a lot of info to keep track of in a card game. If you gather most of it up into a few structs, it really helps minimize the complexity, and make the whole thing much more reasonable to understand.

Icon's are char's because ASCII table has char's for suits of cards:

for(i = 3; i <7 ; i++)
  printf("%c", card_icon);

For a simple console poker program, they look OK. Better than anything I could draw that small, for sure. I was going to post a pic of the output, but both paint and the image software program I have (Irfanview), think that these suit icons should be replaced by question marks.

They work fine on screen, however. I'm dismayed to see that they don't work in these programs.

Adak 419 Nearly a Posting Virtuoso

Good eye, AD, good eye! ;)

Adak 419 Nearly a Posting Virtuoso

You can use a simple distribution count, I believe. Your verbosity left my eyes glazed over a bit. ;)

int count[101] = { 0 }; //assign all elements to zero value

if (your char is a number from 1 to 100)
  count[char + '0']++;

//remember count[0] will not be used here.

This is also called "bin sorting" or "binning", among other terms. Useful trick.

Adak 419 Nearly a Posting Virtuoso

There is an easy solution to this. Use Ira Pohl's theorem, on top of Warnsdorff's algorithm.

iirc, it means if you find two squares that evaluate as equal in connectivity, then you extend the search depth another ply until the subsequent moves do not evaluate to even anymore.

If you go to Wikipedia, on Warnsdorff's algorithm, it has a link to a free version of Pohl's paper on it.

I haven't played with it in a program, but it lead me to believe that you could solve the problem much faster, because it stops "blind alleys".

Didn't see any figures for using it on different size boards, etc., however.

Adak 419 Nearly a Posting Virtuoso

Are you trying to make ONE knights tour from every square on the board, or are you trying to find EVERY knight's tour that is possible, from every square on the board?

Adak 419 Nearly a Posting Virtuoso

I tried putting the code like this

printf("\nMovie Title:");
            fgets(Videos[i].title,sizeof(Videos[i].title),stdin);
            Videos[i].title[strlen(Videos[i].title) - 1] = '\0';

didnt prompt me to enter..it skipped it ..why?

This works, you aren't showing enough of your code for me to tell what's up with it.

void Add_Movie(movie Videos[100]){                         /* this function is for adding Videos,it asks the user to prompt the movie's ID,tile,year,type and avalibility */
  int answer, i,id,year;

  for(i=4;i<100;i++){
    printf("Movie ID:");
    scanf("%i", &Videos[i].id);
    getchar();
    printf("Movie Title:");
    fgets(Videos[i].title, sizeof(Videos[i].title), stdin);
    Videos[i].title[strlen(Videos[i].title) -1] = '\0';
        
    printf("Movie Year:");
    scanf("%i", &Videos[i].year);
    getchar();
    printf("Movie Type:");
    fgets(Videos[i].type, sizeof(Videos[i].type), stdin);
    Videos[i].type[strlen(Videos[i].type) -1] = '\0';
    
    printf("Availability:");
    scanf("%s", Videos[i].availaibility);

    printf("\n Do you want to add another movie? if no, enter 0: ");    /* the function gives the user the choice to continue adding another movie or leaving..0 to exit */
    scanf("%i",&answer);
    getchar();
    if(answer == 0)
      break;
  }
    List_Movie(Videos);                                      /* to call the List_Movie function in order to show the Videos' list after adding*/
}

Note that I did increase the length of title because it wouldn't handle longer strings, there.

Adak 419 Nearly a Posting Virtuoso

That fgets() line of code you tried, was correct.

Whenever you use scanf() family of functions, you have to know how it works. Especially, when it will leave a newline char behind it, still on the keyboard buffer.

Numbers and char's ALWAYS leave a newline behind. It won't bother other scanf()'s for numbers, but it will bother char's (all the time, even one), and strings (if there are two or three of them).

I added getchar()'s after all the scanf()'s in your Add_movie() function, except the strings, and increased the size of the title. "The Hunt for Red October", wouldn't fit as is. ;) Then Add_movie() worked fine.

The getchar()'s don't stop the program, since they are matched up with the newlines present in the keyboard buffer. If you add too many getchar()'s, then it will stop the program, but just the right number, will not stop it, it just pulls the newlines off the keyboard buffer.

After you have the fgets() title into your struct array, you will want to remove the newline that was stored with it. This line of code will do that:

Videos[i]title[strlen(Videos[i].title) - 1] = '\0';

Without the above, the title will print out fine, but the rest of the display, will be down one row, because it still has the newline in it.

Adak 419 Nearly a Posting Virtuoso

Nobody knows your program as well as you do. Don't be afraid to sharpen your own troubleshooting skills.

Narrow down what function first gets bad data (you can bet it's a memory error causing this). A few printf()'s in functions and stepping through the code should do wonders.

And you can do that - and should, imo. How will you learn to troubleshoot your programs if you don't practice? Like here, you didn't mention what function is causing the crash. Why not? Don't be lazy, try to find the problem.

Adak 419 Nearly a Posting Virtuoso

Google is your friend! ;)

Start small, and simple. You have a menu(), a help text describing the game perhaps, a play the game loop, maybe you have alternating turns for the players, you may need to count the turns as the game is played. After every turn, you may need to check if the game is already won (on that last move). Every move may need to be checked for legality, before it's accepted, etc.

And then there are the graphics! ;) ;)

Adak 419 Nearly a Posting Virtuoso

Why don't you read up on the cipher at Wiki:
http://en.wikipedia.org/wiki/Rail_Fence_Cipher

and give it a try. It's not as hard as it might look. Do a couple messages by hand, and you'll see.

I'm sure that several posters could give you a hand with it, when you have a specific question.

Adak 419 Nearly a Posting Virtuoso

Welcome to the forum, Ndovu. :)

When you post code ALWAYS highlight it, and click on the [code] icon at the top of the advanced editor window. That will keep your code, looking good, and easy to study.

And please - just black. Save the red or green for a special highlight for some block or line of code.

So your algorithm here is to first, break up the text into it's words, and write them out to a file. Then what?

What hints did your teacher give you for this assignment?

I'd be tempted to put each word into a 2D array, and then sort them. Then work on the stats needed (since repeated words would be right next to each other then).

It's good to post up your code, so we can see what you're talking about, but it's just as important to ask the specific questions that relate to C. The broad questions/statements like "This doesn't work", really aren't that helpful. You know your teacher, have class notes and reference books you've been reading (hopefully), etc. For that reason the idea department on these programs, kind of falls into your territory, by default.

Think about it, and pop back when you need us - we're here. ;)

If nothing else comes to mind, ask yourself "How would I do this by hand, with paper and pencil". The answer is almost always easier, and can translate into a pseudo-code and …

Adak 419 Nearly a Posting Virtuoso

Your movies array may not be what you expect. If you have
char *moves[100][5];

Although you've neatly typedef'd it to look different, what you have is a char pointer array that is 100 x 5, and not a char array 100 x 5.

All you need is a flat file database.

Why not put the movie characteristics that you want to record, into a record, with fields? In C you'd use a

typedef struct {
  long id;
  char name[40]; //  (or char *name; and malloc the memory later)
  char lead_man [25];
  char lead_lady[25];
  char cat[25]; //category
  char direct[25]; //director
  char *notes; //malloc memory later)
}movie;

movie movies[100];  //make array of 100 records

Anyway, I'd recommend doing something like that. It groups all your data on a film, all together, and it's pretty simple to code one up.

Adak 419 Nearly a Posting Virtuoso

When a function says it shall return a char, and it returns nothing instead. I don't have a lot of confidence that it's working right. ;)

then there's this:

while (_XtStr[_cnt]= (isdigit(_rrA[_cnt]) . . .

Which should be:

while (_XtStr[_cnt]==(isdigit(_rrA[_cnt]) . . .

and a few other compiler errors and warnings. You should at least try to compile your code, and pay attention to the errors that stop it from compiling. There are some other errors, but I'm not doing your homework for you.

If you can't be bothered to pay attention to your compiler errors, there's no reason why I should do it for you.

Adak 419 Nearly a Posting Virtuoso

Take a step back and ask yourself, WHY?

You can use printf() to print out your int array, in a loop, and control just exactly how you want it to appear. So why change the data type, at all?

But let's say you want to really use a char for printing out your int's. What are you going to do when your small range of a char, is exceeded?

I'm just bothered by the choice to go from the direct, to some circuitous route just to print up an array.

Rube Goldberg would love this, but it really bothers me. Google that name if you don't know what it stands for.

jonsca commented: I thought about the Rube Goldberg thing too. +3
Adak 419 Nearly a Posting Virtuoso

Flashback to my old Math teacher, "Mad Dog" Cameron:
==========================================
"
Oh NO! It's too e-a-s-y!!

Can't you see that you need to add an unknown to this?

Can't you see that you need to then just solve it for the unknown?

It's too easy!!

j-2, when j == 9, Oh NO!

i % X = 7, Oh NO!

I can't do any more --- it's too easy!! "
===========================================

Adak 419 Nearly a Posting Virtuoso

I think you might have a problem with the two stack.h files you've included. calcstack.h and stack.h are likely to have some of the same definitions and leave the compiler tied up in knots.

Check for keyboard errors in your code, if they're supposed to be compatible.

Were you supposed to add an #ifndef block of code ?

Adak 419 Nearly a Posting Virtuoso

int j=length;

should be:

int j = length - 1;

and

while(i !-= j)

should be:
while(i < j)

Adak 419 Nearly a Posting Virtuoso

Oops! It's a Zombie thread!

Adak 419 Nearly a Posting Virtuoso

These lines of code violate the C standard, and are ridiculous to boot.

If you dared to write a line of code like that on a job, you'd be in trouble, for sure.

You can't stop this kind of question (and this thread), fast enough.

Adak 419 Nearly a Posting Virtuoso

One = is for assignment. You need two =='s for a test of equality.

All if(something == somethingElse) lines of code, need two =='s.

Adak 419 Nearly a Posting Virtuoso

Do a bin sort/count on it.

for(i = 0; i < NumOFelements; i++)
  binArray[arrayName[i]]++;

Now print it out. You know how many there are of each number. Now get the highest number. And how will you know what number that is?

HighestNumber will equal bin[HighestNumber]

Oy! ;)

Adak 419 Nearly a Posting Virtuoso

Welcome to the forum.

And no, I wouldn't do that. Turbo C is fine for just little assignments at school or home.

Anything really good, you need to move up to something like MS Express or Code::Blocks - both are free, and have the kind of modern memory and features that you need.

I'm a turbo C user and lover, but I'd be doing you a disservice to say keep using it for a nice project like this.

Adak 419 Nearly a Posting Virtuoso

if(s[j] = z)

Test for equality, in this line of code, don't assign a value.

Then go ahead with your logic.

I believe you can delete the Dummy variable, entirely. ;)

Adak 419 Nearly a Posting Virtuoso

I tried that in my old turbo C 1.01 and it failed with 0, but succeeded with '\0', as the end of string marker.

Adak 419 Nearly a Posting Virtuoso

This is the two threads I was referring to. Not everything is about 2D picture processing, but the idea's are similar. The 3D one's just have a stack of 2D images.

I'm sure there's a lot more info on this, on Google. This is all I had, however.

http://www.overclockers.com/forums/showthread.php?t=448097

http://www.overclockers.com/forums/showthread.php?t=450916

Adak 419 Nearly a Posting Virtuoso

This is the MEGA newline killar! ;) ;)

Adak 419 Nearly a Posting Virtuoso

You have your string, and your width. You keep adding char's from your string (including the spaces), until you equal your width.

If your last char is a space, or period (punctuation of some kind), then you're OK, as is.

If you're in the middle of a word, then you have to start subtracting back to the last char of the previous word, to find a stopping point for that line.

In J's example, "time" was just too big to fit into the first line of 12 char's. So you back up and stop at the first space/punctuation mark, less than 12.

"Now is the time" == 15 char's total (count the spaces between words, also).

Back up to the last char of the previous word - 'e' in the, at 10 count. Subtract 10 from 12, and you need to give out two spaces. You have two spaces between words to give them out into:
between Now and is, and between is and time.

Give out the extra spaces (maybe from left to right), until you run out. If you have too many to give out only 1 space per word gap, then you have to start giving out a second one.

Do that until you're out of spaces to give out. Your margins will be equal, then.

Adak 419 Nearly a Posting Virtuoso

Showing that the data still has a newline in it.

Want it gone, also?

for(i = 0; i < strlen(YourString); i++) {
  if(YourString[i] == '\n') {
   for(j = i; j < strlen(YourString)-1; j++)  //shift down all char's above i
     Yourstring[j] = Yourstring[j+1];
}

That should do it.

Adak 419 Nearly a Posting Virtuoso

my advice is that for a beginer first get an binary file of an image and read the file and display using put pixel statement in c.
As u r going to display black and white image u need to set an threshold value above which all the values should be displayed using black colour n rest r white.
Try out this.

I added some code to a program some years back for this. Helped out someone who had a program to enhance MRI images.

I'll have to scour around and find it. As I recall, the array should be unsigned char, and you open the file in binary mode. Raju D sounds like he's on the right path.

As others have mentioned, you need to understand the file format you'll be working with. (there are so many!. :p

@Narue, ygPM

jephthah commented: this thread is 5 years old. the person you are "responding" to posted 1-1/2 years ago. after 200 posts, you should know better than this -1
Adak 419 Nearly a Posting Virtuoso

This isn't what you want:

printf("\"%s\"\n", buffer);
if(charin[strlen(charin)-1] == '\0')

charin[strlen(charin)-1] = 0;

j = strcmp(charin, buffer);

What you want is to get rid of the newline, not the end of string char, and you don't want to add a zero, either. The end of string marker char, IS a zero, but for char's - so your code is doing nothing but replacing one thing, with it's identical twin. ;)

What you want is this:

printf("\"%s\"\n", buffer);
if(charin[strlen(charin)-1] == '\n')  //if the string has a newline

charin[strlen(charin)-1] = '\0'; //replace it and shorten the string
// by one char. Now do the string comparison.                         
j = strcmp(charin, buffer);
//etc.

In C code, a group of letters without an end of string marker char, will compare the same as a proper string which has an end of string marker.

someLetters == someLetters\0

to strcmp().

Not so if one of the above has a newline char, however! :cool:

Adak 419 Nearly a Posting Virtuoso

This sscanf() line looks dodgy to me. Test the return value it gives, and see if it's 2.

//Separa os indices
sscanf(bdata, "%[^':']:%[^':']:%s", p1,p2);
printf("%s\n",p2);

It has 3 % char's in it, and 1 s in it's formatting, but it's going into two variables??

If it's right, explain it to me, please. I am not a sscanf() expert, but I don't understand that formatting for p1 and p2.

Adak 419 Nearly a Posting Virtuoso
fscanf(FilePointer, "%f", &variableName);

All the scanf() family of functions are subject to quitting the first time they receive data that they aren't set up to handle. It's important to check their return value to see if it actually worked or not, (it returns the number of items it has successfully handled), and it should only be used on data that is FORMATTED properly. Data that variies from one week to the next, is not a good candidate for fscanf().

jephthah commented: well said +6
Adak 419 Nearly a Posting Virtuoso

hi every body.......
here i want to ask something about base64 algorithm which is used for the encryption of passwords.........i just want to know that how it works ?????what are the functions used in this algorithm?????any type help.....any link...????

I'm not sure which cryptographic algorithms use base64, but here's some good reads on it:

1) Cryptology portal on Wikipedia - many pages covering old and new methods.

2) Google "nist encryption standard", for a thorough discussion of their selection of the new(er) advanced encryption standard for the USA. Lots of technical details!

If what you want is ONLY base64 info, then I'd google it, directly, and see what it has.

Adak 419 Nearly a Posting Virtuoso

I'm amazed that the Standards for C, have not required that gets() only allow the number of char's that will fit into the destination array, as a default.

How many programs would that break? Seems like if your program was overflowing the buffer array, then you'd WANT to fix it.

I like gets() because it's just more concise, and leaves the newline off, but in it's current form, it's too stupid to be useful.

Adak 419 Nearly a Posting Virtuoso

You have codes for all of this and much more, if you have Turbo C! No one has to give you anything. :)

Start up Turbo C/C++, and select "file" and "new". Now click on "File" again, and "save as". Give your file a short 8 character or less name, and be sure to end it with .c and save it with that filename.

Now press Ctrl +F1 to bring up the help index. Type "poly" to see help and an example of making a polygon. Then press alt +F1, to go back to the main menu. Type circle or line, and repeat.

Now what I'd do if I were new to it, is copy each one of these help pages, into your new program, and put them in between
/*
and
*/

so they won't bother the compiler. Do that for each one of these help pages.

Now, they're right there, and you can refer to them all at once, if you want, very quickly.

There is no function to draw a square or box, however. For that you can draw four lines, or perhaps use poly().

There are box drawing char's in the upper part of the ASCII code. Get out your ASCII char. They have both a single line box drawing char, and a double line box drawing char. That includes all 4 corners, which are each different char's, btw.

Drawing figures can be slow and …

Adak 419 Nearly a Posting Virtuoso

Use fgets(CharArray, sizeof(CharArray), YourFilePointer);

to put each line into the CharArray[80 or so], that you've previously declared.

Now you can use for or while loops, to "walk" through the CharArray[], and pick out the tabs, and spaces, etc.

When you find the line meets your needs, then put the end of string char: '\0', as the very last char. In C, this is NOT a string:

John

THIS is a string:

John'\0'

Even though you don't see the end of string char on your screen, it MUST be there - or it's just a bunch of letters, not a string, to C.

Spaces tabs and blanks will all have a value less than 'A', (hint, hint, hint).

:)

Adak 419 Nearly a Posting Virtuoso

If you have to use graphics.h as your header, then AFAIK, you have to use Turbo C.

We can't do anything about your error messages, unless we want to re-write your compiler, and that is not going to happen.

Use Turbo C and I can help you (probably). I use it myself. Otherwise, don't bother posting. You can't make a Beagle into a Great Dane, no matter how hard you try. They're different, and they always will be different.

Adak 419 Nearly a Posting Virtuoso

Here's some important things to do:

1) This is predominately an English language board. Translate your program into English, and re-post it.

2) In the advanced edit window, highlight your code and click on the [code/b]/b word at the top of the edit window. That will make your program look like a program.

3) use good indentation. Just two to five spaces between levels of code, is a HUGE help to spot errors, quickly and easily. Tabs are not preferred, but one is OK.

4) delete the 'a' before your first include file, and where is your standard include files, like string.h or stdio.h and maybe stdlib.h?

We can help with your program, but my French is on holiday.

Adak 419 Nearly a Posting Virtuoso

I'm just funnin' with ya, J.

gets() should be long gone.

Adak 419 Nearly a Posting Virtuoso

fgets() is the user input function of choice, for serious programs.

Students who haven't got into qualifying user input yet, are frequently left with scanf(). It's used heavily in books teaching C, and by the instructors, as well.

So it's better to learn how to work with scanf(), than to say "don't use it ever". That's good advice for serious program user input, but it's just sticking your head in the sand, for students learning C.

scanf() will be used in their classes, by their classmates and instructors, and by the majority of the books they'll be using for the course.

Just remember that scanf() was designed for FORMATTED input, not for "Miss Piggy practices keyboarding". ;)

Adak 419 Nearly a Posting Virtuoso

... ok, fine , is there anyway to make a folder that can't be deleted... or to prevent a virus from deleting a folder or creating a file?
Edit:I'm not trying to write a virus...come on now...

What you are looking for is something that is entirely up to the operating system - file permissions, authorizations to access certain folders or drives.

You can make it more difficult. I had a virus that did that to me, once. Had to reformat the HD to get rid of it.

I'm not sure why you want to do this, but you can see where it looks like it's a malware/virus topic.

Adak 419 Nearly a Posting Virtuoso

hey, i'm a one-man army on a mission from god.

J, Have you been talking to god again?

You remember what the nice doctor said about talking to god, last time?

;) ;) ;)

Adak 419 Nearly a Posting Virtuoso

After you enter something with scanf(), there will always be a newline char, left in the keyboard buffer.

If you are scanf()'ing for a char, that is critical, because the newline '\n', is itself, a char. So when scanf() pulls in the char (the newline), it says "I've got my char, so I'm leaving", and your code seems to "skip" the scanf() for the char, entirely.

It did not skip it, it just got a char, and went on!

Add this right after your scanf()'s:

getchar();

That will pull one newline, off the keyboard buffer. It's not necessary if the scanf() is only for numbers, because scanf() will skip over whitespace when it's looking for numbers, anyway.
A newline is considered "whitespace", to scanf(), when it's looking for numbers.

jephthah commented: adding getchar is a bandaid. one of those cheap generic bandaids that falls off the first time you jump into the pool. i dont want your nasty bandaids floating in my pool -1
Adak 419 Nearly a Posting Virtuoso

Jephthah, what's the old trick? He wants to re-direct the con stream someplace so the user can't see it?

Geez, i thought the Prince of Persia game was a riot when it turned my screen upside down after my character drank the wrong potion! ;)