949 Posted Topics
Re: In your sorting code, when j is less than, or equal to i, the comparisons are wasted - they're already sorted at that point. So, in the inner loop: [CODE] //same for loop as before, right here for(j = i + i, j < 5; j++) { // same code … | |
Re: You need to look at what is common for all the data lines. One thing they all have, is a space (or two or three, maybe a small tab), between the hours numbers, and the meter reading. Another thing you might notice, is that the hours entry always uses two … | |
Re: [QUOTE=Joey_Brown;1209486]Hello. I would very much appreciate if someone would aid me with a hint. My problem is as follows : read two arrays of chars and merge them into a third array like so : ARR1 :123abc ARR2: rt678iogl ARR3:1r2t36a7b8ciogl The problem must be solved without pointers and string.h Basically … | |
Re: Welcome to the forum, Qwerty_touch. The way it works is, you show what you've got started on the problem/project, and tell us what has you stopped from completing the program. Requesting some work and involvement from the posters, knocks off the "code leeches", who just want their program done for … | |
Re: Tots08: You have to know the basics of printing out a char array, and putting a value into a char array, or you can't do a program on Conway's Game of Life - because that's the heart of the program, right there. You need to hit the books, and /or … | |
Re: [QUOTE=Wizablue;1205926]Hmm, I was trying to load strings from a file(formated) to an 2D Array... but.... [CODE] int j; //new FILE * fp; char TempBuffer[101]; char array_game[100][100]; fp=fopen(filename,"r"); for(i=0; i<100; i++) // Create 2D array to Hold the array of the file { for(j=0; j<100; j++) { fgets(TempBuffer,100,fp); TempBuffer[100] = '\0'; … | |
Re: [QUOTE=mariosbikos;1199292]i know but i really cant make it up in my mind....so even an example would help i mean in my mind my code is right but windows say no.....[/QUOTE] If I were looking for help on an English programming forum, I'd be sure to translate my program into English, … | |
Re: OK, let's go with "moving around". ;) If your compiler has the header file "conio.h", then the problem is trivial. This program shows how to pick up the scan codes from a keyboard These define the scan codes(IBM) for the keys. All numbers are in decimal. [CODE] #include <stdio.h> #include … | |
Re: puts() adds a newline char to the end of the string. printf(), doesn't do that. Best way to understand your code is to step through it with the debugger, and watch the value of b(). Then you can see exactly what strncpy() is doing. The first 7 char's in a() … | |
Re: Have you tried using a Hex Editor? (HexEdit is a freeware version, available at popular download sites like Toucow, etc.). I'm not sure you can find what you want, however. | |
Re: Suggestions for your Binary search function: [CODE] # int DoBinarySearch(char name[], char czStudentName[][16], int N, int *FoundPointer) { int Middlepoint,i=0; int LowerB= 0; int UpperB= N-1; You don't want a pointer set to -1. You want the index of the student, in the array, if found. Middlepoint already gives you … | |
![]() | Re: The compiler is complaining because you have not given it a prototype for the runner function. ![]() |
Re: Welcome to the forum manju_b. A few suggestions on using this forum: 1) Don't post onto a thread that is more than 3 months old. Start a new thread, instead. 2) Always post any code, inside code-tags, so it looks like a program and not all squashed to the left … | |
Re: This show one way of checking a peer group (row, column, or box), in Sudoku. (At least, it's a version that will make sense to you. The faster versions are rather opaque.) [CODE] int TestRows(int nudigit, int r) { int c = 0; while(nudigit != A[r][++c] && c < 10); … | |
Re: I think this is an easier way: 1) Generate every 2 digit number, and put it into an int array[100]. Just one dimension is needed. Note that you will have only 89 2 digits numbers, in the range 10 - 99. 2) Now your program selects a rand() % N … | |
Re: [QUOTE=idlackage;1197176]The number I'm looking for is valid when it's positive, and nine digits. I used ( (value >= 100000000) && (value <= 999999999) ) first, which worked okay, but did not account for leading zeroes. How do I validate a nine digit number, using only math and no functions, with … | |
Re: You need to change the file name extension, right off! Recommendations: 1) Dot cpp is the default file extension for C++, so it can cause much confusion and wasted time. Change it to just dot c, and then we're at least running on the same language compiler 2) gets() is … | |
Re: Maybe the idea was to simply explicitly print the answers, and getting the data columns, lined up. There is no choice needed, so no if statement is necessary, imo. Standard practice would be to use a loop to print this table up. | |
| |
Re: you have 10 minutes in which you can edit your code, and make it look right. After that, you can't. Click on the "edit" button, then click on "go advanced" button. Now highlight your code with the mouse, and click on the [code] icon at the top of the advanced … | |
Re: I'd suggest using a for loop, and incrementing the number to be tested by 14, with each loop. Put all your other tests that you need, right inside the for loop. [CODE]for(i = 0; i <=R; i+= 14) { //etc }[/CODE] | |
Re: Hosam, why don't you read up on that topic at Wikipedia or in your text or class notes, and apply it into a program. What you want to do is find out when you have it working right, and have something you can copy, and keep it as a reference … | |
Re: Looks good to me. Now start from the beginning of the string, find the innermost set of parenthesis, and perform the indicated operation. I mean, reduce each part of the expression, by one level. Then reduce it by another level, and you're done. | |
Re: Didn't you forget the rule about "Must not use any cpu cycles"? ;) | |
Re: An outline in pseudo code: [CODE] char map[10][10] char myString[12] for(each row) { fgets(myString, 10, filePointer); k = 0 for(each column in the row) { map[row][col] = myString[k++] } } [/CODE] | |
Re: [CODE] #include <stdio.h> int main() { int num,i, j; num = 2; while(num % 2 == 0) { printf("\nenter any odd num"); scanf("%d",&num); getchar(); //not essential, but good. } //c'mon, this is C, we count "zero, one, two...", unless there's a //good reason for starting elsewhere, start at zero. for(i=0;i<num;i++) … | |
Re: In your sort, you only have one loop. [CODE] for(k=0; k<N-1; k++) { if(a[k]>a[k+1]) { temp=a[k+1]; a[k+1]=a[k]; a[k]=temp; } } [/CODE] Which you'd see in an instant, if it was properly indented: [CODE] for(k=0; k<N-1; k++) { if(a[k]>a[k+1]) { temp=a[k+1]; a[k+1]=a[k]; a[k]=temp; } } [/CODE] And there is only one … | |
Re: Right off the bat, I don't like float data types for parties and bdays. No one has 1/4th of a party, or .01 bdays. Unless there is a specific need for floats or doubles, don't use them! They have their own subtle problems. You will need two nested loops: [CODE]for(each … | |
Re: Seems like you could scanf() and get a number from the user and then use a for loop to print out the lines of *'s, alternating between the user's number of *'s, and two *'s. So every time your iterator in the loop is even, you want the user's number … | |
Re: Line 11 overwrites the newline char from the char name[]. Your search function has two types of searches: 1) for a specific char, and 2) for general info on the entire string. So how about passing a '0' (zero) char, for a general, non-specific search, and anything else could be … | |
Re: Sure there is! You can use strchr() to look for a char in the string, or strstr() to look for a sub string in the string, same as if your char array was outside the struct. There is no difference, except you need to use the dot operator to access … | |
Re: Strings don't need to be returned from a function. When you send a string to a function (which is what you want to do), you are sending a constant pointer (which is the name of the char array, itself). And since the function has the address, rather than just the … | |
Re: Yes, everybody except those condemned to Hell. They have to use "Brainluck" language. ;) ;) (but with an f in place for the l letter) Wikipedia search it for a laugh. | |
Re: [QUOTE=Toysh;650029]I am a beginner trying to write a program for my intro C class. I am trying to write a program that calculates the combination of numbers given a specific output by the user. The number has to be between 1-10 to be valid. I am not allowed to use … | |
Re: 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. | |
Re: You haven't given enough information to solve the problem, yet. | |
Re: [QUOTE=scrappy57;1175810]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[/QUOTE] Only older kernels that … | |
Re: 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 … | |
Re: You can use a simple distribution count, I believe. Your verbosity left my eyes glazed over a bit. ;) [CODE] 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 … | |
Re: Take all the way too many cooks, out of the kitchen -- they're spoiling the meal. Make a struct for each card: [CODE]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]; [/CODE] There's … | |
Re: This isn't what you want: [CODE] printf("\"%s\"\n", buffer); if(charin[strlen(charin)-1] == '\0') charin[strlen(charin)-1] = 0; j = strcmp(charin, buffer); [/CODE] 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, … | |
Re: int j=length; should be: int j = length - 1; and while(i !-= j) should be: while(i < j) | |
![]() | Re: 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? |
Re: 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 … | |
Re: Do a bin sort/count on it. [CODE]for(i = 0; i < NumOFelements; i++) binArray[arrayName[i]]++; [/CODE] 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! ;) | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … |
The End.