949 Posted Topics

Member Avatar for Xufyan

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 …

Member Avatar for sourabhtripathi
0
99
Member Avatar for tquiva

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 …

Member Avatar for Adak
0
163
Member Avatar for Joey_Brown

[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 …

Member Avatar for Adak
0
402
Member Avatar for qwerty_touch

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 …

Member Avatar for 0x69
-1
160
Member Avatar for tots08

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 …

Member Avatar for tots08
0
151
Member Avatar for Wizablue

[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'; …

Member Avatar for Wizablue
0
490
Member Avatar for mariosbikos

[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, …

Member Avatar for mariosbikos
0
276
Member Avatar for tquiva

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 …

Member Avatar for Adak
0
3K
Member Avatar for newbiecoder

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() …

Member Avatar for newbiecoder
0
672
Member Avatar for tomtetlaw

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.

Member Avatar for jephthah
0
153
Member Avatar for emmas4impact

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 …

Member Avatar for Adak
0
135
Member Avatar for OzY360

The compiler is complaining because you have not given it a prototype for the runner function.

Member Avatar for OzY360
-1
205
Member Avatar for manju_b_2006

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 …

Member Avatar for Adak
-2
593
Member Avatar for rlhh

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); …

Member Avatar for Adak
0
169
Member Avatar for d34dw4rd
Member Avatar for mariosbikos

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 …

Member Avatar for Adak
0
118
Member Avatar for idlackage

[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 …

Member Avatar for jephthah
0
139
Member Avatar for Gordon209816

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 …

Member Avatar for Adak
0
120
Member Avatar for Signal_Hill

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.

Member Avatar for Adak
0
93
Member Avatar for thomasekugm
Member Avatar for yasy

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 …

Member Avatar for Adak
0
111
Member Avatar for Ammar1990

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]

Member Avatar for Adak
0
119
Member Avatar for hosam2k

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 …

Member Avatar for hosam2k
0
152
Member Avatar for Muhammadlodhi

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.

Member Avatar for Adak
0
151
Member Avatar for pramoda.ma
Member Avatar for mariosbikos

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]

Member Avatar for mariosbikos
0
293
Member Avatar for Muhammadlodhi
Re: HELP

[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++) …

Member Avatar for Muhammadlodhi
0
260
Member Avatar for alcx88

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 …

Member Avatar for Adak
0
131
Member Avatar for LMat619

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 …

Member Avatar for WaltP
0
249
Member Avatar for Muhammadlodhi

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 …

Member Avatar for Salem
-2
364
Member Avatar for hosam2k

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 …

Member Avatar for Adak
0
144
Member Avatar for vizionary2012

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 …

Member Avatar for Adak
0
104
Member Avatar for jgehlot09

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 …

Member Avatar for Adak
0
98
Member Avatar for sharathk60

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.

Member Avatar for Ancient Dragon
0
140
Member Avatar for Toysh

[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 …

Member Avatar for peter_budo
0
497
Member Avatar for scrappy57

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.

Member Avatar for Adak
0
90
Member Avatar for Slobodino
Member Avatar for craig_ka
0
131
Member Avatar for scrappy57

[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 …

Member Avatar for jephthah
0
81
Member Avatar for papia maity

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 …

Member Avatar for Adak
-2
48
Member Avatar for max.v8

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 …

Member Avatar for max.v8
0
181
Member Avatar for whatThewhat

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 …

Member Avatar for whatThewhat
0
129
Member Avatar for HeavySoul

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, …

Member Avatar for girishn
1
134
Member Avatar for doom5

int j=length; should be: int j = length - 1; and while(i !-= j) should be: while(i < j)

Member Avatar for girishn
1
143
Member Avatar for Vytautas

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?

Member Avatar for jephthah
0
1K
Member Avatar for deeer

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 …

Member Avatar for deeer
0
758
Member Avatar for jsp133100

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! ;)

Member Avatar for Software guy
0
111
Member Avatar for lyn.vita

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 …

Member Avatar for Adak
0
140
Member Avatar for jacksparao

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 …

Member Avatar for Adak
0
93
Member Avatar for ndovu

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 …

Member Avatar for Adak
0
135
Member Avatar for Yggdrasil

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 …

Member Avatar for jephthah
0
171

The End.