949 Posted Topics

Member Avatar for virendra_sharma

It's hard to take your request seriously when you post up some code that won't even run. There are lots of other posts on this subject, here and all over the net. Also, check out the Sieve of Eratosthenes, on Wikipedia, etc. Come back with a full program, and then …

Member Avatar for Adak
-1
137
Member Avatar for coding101

Morse code has no equation or algorithm to figure out it's series of dots and dashes. It was made for brevity and ease of understanding, not computer algorithms, unfortunately for us. ;)

Member Avatar for Adak
0
90
Member Avatar for zetologos

My eyeballs get tired just studying your code. ;) Instead of two arrays to convert letters from one case to the other, why not use toupper() or tolower() (part of ctype.h)? Another easy way would be to simply use the ascii values. Since there is a constant difference of 32 …

Member Avatar for zetologos
0
261
Member Avatar for yoshitsugu

Step through the code with a debugger, and watch the values of the variables, as they change. Use asserts and print statements as needed, to help you debug it. This is not a "shades of grey" thing. If your function is wrong, then find the bug. Troubleshooting code is an …

Member Avatar for L7Sqr
0
188
Member Avatar for ajayb

ptr is being given a new address, in the assignment statement ptr=&val, in fn(). It no longer has anything to do with i.

Member Avatar for Adak
0
100
Member Avatar for f1r0z3

Break it down into a few big steps (amid smaller one's): 1) Get your connect 4 program using one thread, working PERFECTLY. No crashes, no illegal moves, etc. It's difficult to debug a multi-threaded program, so get the single threaded version of your code, working really spot on. 2) Now …

Member Avatar for Adak
0
236
Member Avatar for jimu

I used a char array char filename[SIZE], and a char *extension = ".txt". I used an unsigned int for the number. As the program looped around for another filename increment, the file_num++, of course. iota() from ctype.h, was then used to put the number into the filename char array. Then …

Member Avatar for jimu
0
206
Member Avatar for mikecolistro

To fill the array with unique int's from 1 to 52, just use: [CODE] for(i=0;i<52;i++) array[i] = i+1; [/CODE] Then you can swap random indeces around, until it's all shuffled [CODE] for(i=0;i<someNumberAtLeast25;i++) { temp = array[randomInt]; array[randomInt] = array[randomInt2]; array[randomInt2] = temp; } [/CODE] Give that a try. ;)

Member Avatar for mikecolistro
0
154
Member Avatar for sketchiii

Clocks aren't as easy as they look. For instance, Sleep(N) gives you AT LEAST N periods of time - but note the "at least" part of that. ;) Because other programs and lots of Windows services (programs without a terminal window for output), are running, many times you'll get more …

Member Avatar for Adak
0
224
Member Avatar for ram619

First suggestion is to Google for a C program called "Matrix". it uses this technique to simulate the graphics of the Matrix movie (falling chars), in the console window of your VDU. It uses pointer notation, but remember that this: *(myArray + i) is the same as myArray[i], so therefore …

Member Avatar for Adak
0
622
Member Avatar for chess2009

Please don't immediately cross post your question on multiple boards. This has already been answered "over there". :(

Member Avatar for Adak
0
132
Member Avatar for westony

det is a single char. You're trying to make it a string, and it can never be a string, since it has no room for an end of string char '\0' to go on the end of it.

Member Avatar for westony
0
110
Member Avatar for Luckychap

Well, phi isn't used in any of the "line" functions, so that can be deleted. I don't understand why you used 3.1423. Wouldn't 3.1416 be closer? It's a very nice program. My critique of it would be that's it's logic is not as simple as it should be. You used …

Member Avatar for Adak
0
2K
Member Avatar for Dawn76

The best way to start a program, is frequently to work it through by hand, on paper. How would you do this, without a computer? You might use a row of an order form, where columns denoted the features the order desk should have, with a sub-total of the price …

Member Avatar for Adak
0
116
Member Avatar for tom1252

In main() you [B][COLOR="Red"]MUST[/COLOR][/B] call the bubble() function, if you want the program to use that function and sort.

Member Avatar for Adak
0
126
Member Avatar for jacob21

The way this forum works is that YOU are responsible for posting up your try to solve the assignment/exercise. So post your code (and do paste it between the code tags you get by clicking on [code ] icon in the editor), and tell us what has you stumped. Regarding …

Member Avatar for gerard4143
0
113
Member Avatar for ram619

Your code is very verbose, and overly complex. Try and keep it short, simpler, and thus faster. Like this: [CODE]void insertionSort(int A[], int lo, int hi) { int i, j, val; for(i=lo+1;i<hi;i++) { val = A[i]; j = i-1; while(A[j] > val) { A[j + 1] = A[j]; --j; if(j<0) …

Member Avatar for Adak
0
187
Member Avatar for kayhantolga

There are four arrow keys. Each gives two bytes, the first one is 0 or 0x00 in hex. The second byte determines which arrow key: 0x48, 0x4b, 0x4d, 0x50 for up, left, right and down, respectively. You should download an ASCII char and key scan code chart, if you don't …

Member Avatar for kayhantolga
0
88
Member Avatar for Oblivious21

When you have several fields which all relate to the same object, you create a struct which will group the different fields (members of the struct), into one record (struct). Then you use the dot member to access any member of the struct: system.date system.type system.os system.version etc. Which you …

Member Avatar for Adak
0
266
Member Avatar for arun_taurean

No, I haven't heard of that one, but Google and Wikipedia have a lot of information on all kinds of ciphers. Wikipedia has an entire portal dedicated to Cryptology - neat stuff. With all the interest in protecting info these days, you should have no problem Googling successfully for it. …

Member Avatar for Adak
0
330
Member Avatar for zychos

One = char is for assignment in C. Two == char's are used for comparisons. [CODE]if(variable == someValue);[/CODE] This is the pseudo code for a nested loop version of bubble sort: [CODE]procedure bubbleSort( A : list of sortable items ) n = length(A) for (i = 0; i < n; …

Member Avatar for Adak
0
149
Member Avatar for frogit

Instead of using a number of arrays, I would use just one 2D array for the positions. Servo 0 would have all it's positions in order, on row 0, cols 0 thru N Servo 1 would have all it's positions in order, on row 1, cols 0 thru N Servo …

Member Avatar for frogit
0
622
Member Avatar for keicola

You've put in the wrong tags. For links, no tags are needed, can you fix it quickly? After 30 minutes, you can't edit your post on the forum. Welcome to the wonderful world of pointers/addresses running amok! ;)

Member Avatar for keicola
0
174
Member Avatar for arends

[CODE] printf("Enter 2-character state code: "); scanf(" %c",&stateCode); for(i = 0; i < NAME_LEN; ++i) { if (custArray[NAME_LEN].state == stateCode); //this is the line I am having a problem with printCustArray(custArray[i]); } [/CODE] 1) You're instruction say to enter a 2 char state code, but %c will only handle one …

Member Avatar for arends
0
180
Member Avatar for joelem

What formatting works with printf(), will work with fprintf(), and the formatting that works with scanf(), will also work with fscanf(), and sscanf(), etc. Nearly all of the printf() formats, also work the same in scanf(). There are a LOT of formats for each of these. The right format for …

Member Avatar for Adak
0
1K
Member Avatar for gyuunyuu

You can use a modified bubble sort if you make two changes: When you find a char that needs to be swapped, you move the entire row of char's (the whole word). Instead of comparing one column's char with the column next to it, like the regular bubble sort, you …

Member Avatar for Adak
0
1K
Member Avatar for knight92

C/C++ offers several advantages: 1) some free compilers, as well as competing commercial compilers, and a huge base of libraries. VB has none of these, that I know of. 2) a huge installed base of trained C/C++ programmers 3) there are a wide variety of compilers. One or more, for …

Member Avatar for Adak
0
364
Member Avatar for lisaroy1

On older Windows (3.1 type), you need them, because it used the old 16 bit addressing memory mode. With newer Windows, you will have to remove the far designation, or you'll get an error, even if you're using an older 16 bit, version of a compiler. I use a very …

Member Avatar for Banfa
0
230
Member Avatar for Paritosh Das
Member Avatar for Adak
-1
145
Member Avatar for anirudhruia

So the advice that was given to NOT use gets(), and to USE code tags, was completely lost on you? Try again. ;)

Member Avatar for vinayakgarg
0
102
Member Avatar for ram619

You didn't show a return type for the prod() function. Also, you didn't add the prototype to the function, before main(). The prototype is just like the first line of the function, but doesn't need the name of the variables, just the type. Put that below the include files, before …

Member Avatar for lisaroy1
0
387
Member Avatar for harikrishna439

By convention, x and y denote a range of values in the horizontal and vertical direction respectively, on a plane. Taken together, they give the exact location of any point on that plane. Common name - coordinates or Cartesian coordinates. So draw yourself a graph and label some x and …

Member Avatar for himam
0
137
Member Avatar for Dionysus

The earlier posts are from 2009, so I doubt they will answer your questions. You need to start a new thread with your problem, and let this one be buried, again. ;)

Member Avatar for Adak
0
730
Member Avatar for dandixon

I don't know if you can do this in Excel easily, but it's trivial for a program to take your data, make these changes, and give it back to you. You know how to export a file from Excel, in text format? Do you know how to import a file …

Member Avatar for debasisdas
0
78
Member Avatar for G_Waddell

I would ask this in one of the MS usenet groups (in newsgroups). This issue must be affecting others. Your answer may be there waiting for you, already. In any case, you can get good answers, rather quickly there. Good luck.

Member Avatar for G_Waddell
0
413
Member Avatar for atticusr5

The phrase "C does not want to play ball", is not nearly as helpful in troubleshooting your program, as you seem to believe it is. ;) Use your debugger or add some printf() statements in your code, and give us the real problem you're seeing with your program.

Member Avatar for atticusr5
0
170
Member Avatar for Hey90

When you don't use code tags, your code looks like the dog's breakfast, and is generally ignored. Always highlight your code, and click on the [CODE ] icon in the top bar of the forum editor, to make your code easily readable. First thing I see wrong is the & …

Member Avatar for Adak
0
257
Member Avatar for aimbo

When I deal with a string like this, that just isn't "quite right", the first thing I like to do, is make it "right". [CODE]char str[]="1,3,5-9,10,12-14";[/CODE] One pass through a for loop would remove both the comma's, and replace the hyphens with a space. Then, use sscanf(), to get all …

Member Avatar for Adak
0
145
Member Avatar for pooran.c

What have you tried? With linked lists, it's best to study it, and have a good sample program that you know works, to refer to while you are troubleshooting your own program. I would either refer to your class/book notes on it for this, or grab a none good program …

Member Avatar for Ezzaral
0
129
Member Avatar for MichaelSammels

So the struct will need two members, something like: [CODE]struct mystruct { char name[20]; char passwrd[10]; } [/CODE] Before main(), then in main(), create the struct itself: [CODE]struct mystruct mine[20];[/CODE] and now you have an array of twenty records. Pass mine around like any other array, to your other functions, …

Member Avatar for Adak
0
174
Member Avatar for iwanttolearnc

Ok, what have you tried to troubleshoot this? Have you tried sending the data at slower speed? That would be my first test.

Member Avatar for Adak
0
214
Member Avatar for Joey_Brown

Each student will typically be taking several courses each semester, so adding more classes into your student struct, would not be unreasonable. Two other alternatives: 1) Add a classes struct, and nest it inside your student struct. The one I like best is an array of char, where each class …

Member Avatar for Adak
0
174
Member Avatar for tacker

You made an array with only 1 row, 1 column, and 1 depth. Since arrays in C always begin with subscript 0, trying to refer to [1] in any dimension, is junk - you're out of bounds. ;)

Member Avatar for tacker
0
236
Member Avatar for steve_27

So your logic needs to consider the lowest number first, and then continue adding the lowest number, until it's >= 5. If it's == 5 then print it. Then you pop off the next number from the stack, and having backtracked to one for the second number, trying adding more …

Member Avatar for Adak
0
108
Member Avatar for lisaroy1

I'm thinking databases are not the topic for relative newcomers to take on. Why don't you Google MySql and see if that meets your needs? It's open source, and there's a ton of info on the net regarding it's usage.

Member Avatar for Adak
0
83
Member Avatar for terabyte

Double your getchar()'s, and all will be well. When you enter a char, you hit the the enter key, putting a newline ('\n') char into the keyboard stream (stdin). The first getchar() pulls off only the char you pressed BEFORE you hit enter, leaving the newline behind - and lets …

Member Avatar for terabyte
0
105
Member Avatar for p0l4rb34r

Get a good IDE, and understand, it will take time and a lot of work to be a decent programmer. Learning C from the command line -- holy shit! Insane confidence killer, for a beginner. imo.

Member Avatar for asterix15
0
175
Member Avatar for Rass Saee

Makes sense it might do this, doesn't it? First, it makes room for f[], then it makes room for g[]. Nothing in between is made, so it's quite probable that f[] is just beneath or above g[]. When you "walk" off the end of f[]'s boundary, what might you very …

Member Avatar for asterix15
0
100
Member Avatar for PCSAWICK829

There's nothing wrong with your code - runs fine. There are some good C IDE's (integrated development environments), with editors, help buttons, and messages from the compiler and linker, and debugger. Visual Express from Microsoft is one, and Code::Blocks is very good, as well, although it's separate from the compiler. …

Member Avatar for anirudh33
0
255
Member Avatar for alexchen

The device you're working with, only works from top line to bottom line (unless you do some repositioning of the cursor, which is not needed here). print the top line of *'s in a loop: print the left side * print the spaces needed, then print the right side * …

Member Avatar for alexchen
0
173

The End.