Posts
 
Reputation
Joined
Last Seen
Ranked #362
Strength to Increase Rep
+5
Strength to Decrease Rep
-1
100% Quality Score
Upvotes Received
15
Posts with Upvotes
14
Upvoting Members
10
Downvotes Received
0
Posts with Downvotes
0
Downvoting Members
0
7 Commented Posts
~21.5K People Reached
Favorite Forums

55 Posted Topics

Member Avatar for rollercoaster

There are three ways you can do this. The first one (and the not-so-basic one) is making use of [i]pointers[/i]. You can declare the cross-function variables inside main, and pass their addresses to the other functions, which, in turn, will modify the initial variables. Here's a sample, but unless you …

Member Avatar for Manali_2
0
4K
Member Avatar for suhrud.l
Member Avatar for dragonpunch

You could have a look over [url=http://zlib.net]zlib[/url], I think it's your best bet.

Member Avatar for Ninetie
0
158
Member Avatar for tutun01111

[QUOTE=WaltP;1374475]Answering a C question with C++ is worthless. And using gets() and getch() is so wrong it's close to criminal. And do I really need to mention CODE Tags? The Member Rules are quite clear...[/QUOTE]What I find to be even more disturbing is the fact that this guy's created an …

Member Avatar for Caeon
-2
95
Member Avatar for creeps

This one is pretty strange (or at least I can't figure out what triggers it). I have the piece of code below, but there seems to be a bug with the second call of [icode]scanf[/icode]. It simply gets skipped. So the input should be something like [code] 10 3 fbfbfbfbfb …

Member Avatar for creeps
0
103
Member Avatar for creeps

Yes, it's yet another thread about implementing three basic operations (addition, subtraction and multiplication) on abnormally large numbers (> 100 digits). I've stored each digit inside an array of [icode]int[/icode]s, as the following piece of code illustrates [code=C] while((ch = getchar()) != EOL) a[len_a++] = ch - CHR; [/code] Now, …

Member Avatar for Shift-Stop
0
254
Member Avatar for Pooch74

The main problem with your code is that the arrays should not be passed using the address operator (&). So if you wanted to pass the array to your [icode]countEven[/icode] function, you'd use the following [code=C] countEven(numbers); [/code] This is mainly because the name of the array is a pointer …

Member Avatar for Pooch74
0
98
Member Avatar for stud02

You could create a header file. That is, take all the function definitions and prototypes from the first C file, put them in another .h file, and then use [icode]#include "header_file.h"[/icode] after you include the standard headers in your second C program. For example header.h [code=C] #include <stdio.h> void my_printf(const …

Member Avatar for WaltP
0
116
Member Avatar for Abdullah Amjad

You simple write its name and pass it the arguments. For example: [code=C] #include <stdio.h> int main(void) { /* printf *is* a function, and that's how we call all the other functions */ printf("I am %d years old\n", 15); return 0; } [/code] Going a step further and tokenizing the …

Member Avatar for hyperion
0
143
Member Avatar for swapnaoe

It actually explicitly states that the assignment to [icode]i[/icode] is of [icode]unsigned long[/icode] type. Given the piece of code you've posted above, if you use something like [url=http://splint.org/]splint[/url] to check your code, you get a warning, stating that the assignment to [icode]i[/icode] is of incompatible type. There are few cases …

Member Avatar for Adak
0
189
Member Avatar for devesh2222

If you're looking for the Assembly code and are using gcc, use the -S command line argument, and the output file will contain the code.

Member Avatar for Martin B
0
98
Member Avatar for XMasterrrr

I agree with Narue that [url=http://www.amazon.com/C-Programming-Modern-Approach-2nd/dp/0393979504/ref=sr_1_1?ie=UTF8&s=books&qid=1287055790&sr=1-1]C Programming: A Modern Approach[/url] is [i]the[/i] book for learning C. That's how I've learnt it, and I'm pretty satisfied with what I've got under my belt. Now, there's also [url=http://www.amazon.com/Without-Fear-Beginners-Guide-Makes/dp/0321246950/ref=sr_1_1?ie=UTF8&s=books&qid=1287055864&sr=1-1]C++ Without Fear[/url]. Ok, it's on C++, but I've found it to be quite the …

Member Avatar for XMasterrrr
0
165
Member Avatar for BLUEC0RE

Why [icode]scanf[/icode]? Are you familiar with [icode]getchar[/icode]? It's better suited for your needs. With [icode]getchar[/icode], it's as simple as [code] while(c = getchar() != '\n') [/code] Also, if I remember correctly, using a [icode]char[/icode] to check for EOF is not going to work, for [icode]char[/icode] is an unsigned data type, …

Member Avatar for gerard4143
0
3K
Member Avatar for sree_ec

Read a good book on it, but it might be a little too expensive for just file I/O. If you're looking for a reference, check the Dinkumware link in my signature.

Member Avatar for itpungaraja
0
239
Member Avatar for myk45

Because in C, const != "constant", but "read-only". That is, it is legal to initialize a const variable using [code] void f(int n) { const int m = n / 2; } [/code] but its value is dependent of n. So if we call f passing first 2 as argument, …

Member Avatar for gerard4143
0
88
Member Avatar for Katana24

No, you just have to change the linking. Before I tell you how to do this, though, I recommend you switch to Terminal + MacVim. Using an IDE in the beginning is overkill, as well as hiding certain aspects away from you. Now, after you create a new file (again, …

Member Avatar for creeps
0
217
Member Avatar for abhiab1991

[QUOTE=abhiab1991;1346887]1) Write a program to count the number of blank spaces in a given string. 2) Write a program to abbreviate a given string (e.g. if the input is Amar Akbar Anthony, the output will be AAA)[/QUOTE] 1. Go through the string, and increment a counter when you encounter a …

Member Avatar for abhiab1991
1
133
Member Avatar for Snader

The program is [b][color=red]wrong[/color][/b]. Here's why: First of all, you are not including a header file, therefore, you have no access to the I/O functions (i.e. [icode]scanf[/icode]). Next, you define [icode]main[/icode] as [icode]void main()[/icode], when it should be [icode]int main(void)[/icode]. Furthermore, you write [icode]scanf("%d", a);[/icode]. This is incorrect, as the …

Member Avatar for N1GHTS
0
130
Member Avatar for eman 22

Was it really necessary that you bumped it? An [b]abstract data type[/b] is a data type whose representation is hidden from the client. A [b]heap[/b] is an array object representing an incomplete binary tree. A [b]stack[/b] is a set of items in which the element to be deleted is known …

Member Avatar for N1GHTS
-1
102
Member Avatar for MKDWOLF

A good first step would be reading [url=http://en.wikipedia.org/wiki/Bus_error]the Wikipedia article[/url]. If you still don't manage to solve the problem, post some code here.

Member Avatar for abhimanipal
0
97
Member Avatar for gurushankar

The ## operator [i]pastes[/i] two [i]tokens[/i] together (this is why the operation is called the [i]token-pasting[/i] operation). In the above code, a function is defined as a macro, which, when given two arguments (var and 12, in our case), forms a single token (in our case, an [i]identifier[/i]), var12.

Member Avatar for gurushankar
0
102
Member Avatar for varun mca

A [i]parameter[/i] is used when defining/declaring (or prototyping) a function, and an [i]argument[/i] is passed (or given) when calling the function. In the example below, [icode]x[/icode] and [icode]y[/icode] are parameters, while [icode]a[/icode] and [icode]b[/icode] are arguments: [code] double average(int x, int y); /* Function prototyping; x and y are parameters …

Member Avatar for creeps
0
120
Member Avatar for litsluv

[QUOTE=Adak;1336005][...] you chose to declare new variables throughout the code. That's OK for some (few) newer compilers, but mine won't put up with it. If you declare your variables at the start of the function, then I can assist you further.[/QUOTE]Hmm... this could have been easier to fix w/ a …

Member Avatar for Adak
0
209
Member Avatar for challarao

I think you [i]could[/i] install a GCC version for Windows through [url=http://www.cygwin.com/]Cygwin[/url]. When I was programming on Windows, I was using an IDE, [url=http://www.codeblocks.org/]Code::Blocks[/url].

Member Avatar for Auraomega
0
313
Member Avatar for furqankhyraj

I think you should learn the language's basics better (if you're 4/10), and then pick a project you're motivated about enough to finalize it.

Member Avatar for creeps
0
102
Member Avatar for susin

I think you need [url=http://www.dinkumware.com/manuals/default.aspx?manual=compleat]a reference[/url]. You can also check the header files on your own computer, installed by the compiler.

Member Avatar for Auraomega
0
281
Member Avatar for gudads

I haven't used Xcode in a while, but since you've got it installed, open TextEdit (unless you're comfortable with a command-line text editor, of course), write your program in there, and save it as [b]attempt.c[/b] in your [i]home directory[/i] (the one with Movies, Music, and so on). Next, fire up …

Member Avatar for knobcreekman
0
284
Member Avatar for widapol

I can't really figure it out. Why do you (Ancient Dragon) keep posting C++ code in the C section? Am I missing something?

Member Avatar for zark_yoc
-1
232
Member Avatar for kloony

Because you declare [icode]acName[/icode] as a [i]character [b]pointer[/b][/i]. That is, you cannot change individual letters. All you can do is have it point to another string. So you could write [code] #include<stdio.h> #include<stdlib.h> int main(void) { char *acName="hello daniweb"; *acName="H"; printf("%s\n",acName); } [/code] and the output would be [icode]H[/icode]. In …

Member Avatar for creeps
0
199
Member Avatar for harikrishna439
Re: gets

Well... the easiest way to avoid getting warnings is to write correct programs. Perhaps post some actual code. You can force gcc to hide warnings by compiling with the [icode]-w[/icode] flag. Note the lowercase.

Member Avatar for Narue
0
102
Member Avatar for nigelmercier

Try [code] digit[curpos] = (++digit[curpos]) % 10; [/code] The reason your code doesn't work is because it uses a [i][b]postfix[/b] increment operator[/i]. This means that the incrementation takes places [i]after[/i] the statement it can be found in has been executed. That is, the first piece of code below can be …

Member Avatar for mitrmkar
0
345
Member Avatar for nigelmercier

The problem in your approach is that your mind is stuck to thinking from left to right. Try thinking from right to left. That is, compute d1, then d10, then d100. You also don't need the digit you've just stored anymore, so you're free to drop them. To give you …

Member Avatar for nigelmercier
0
213
Member Avatar for Castiel1631

Is [b]encrypted.txt[/b] in the same folder your program is in? Also, what operating system are you running?

Member Avatar for creeps
0
93
Member Avatar for challarao

Adding to what has already been written, if you're looking for a more formal piece of information, I suggest you should [url=http://www.acm.uiuc.edu/webmonkeys/book/c_guide/2.12.html#printf]check here[/url].

Member Avatar for creeps
0
100
Member Avatar for creeps

Elaborating on the title, I'm trying to complete an exercice in K.N. King's [i]C Programming: A Modern Approach[/i] which requires me to accomplish the task in the quote below. My idea works, but the program does not return control to the OS. I've nailed the problem down to the do/while …

Member Avatar for Narue
0
158
Member Avatar for Mehh

Mate, just look at your code and try to make some logic out of it. Here, I'll give you a hand. On [icode]line 7[/icode] you have a [i]closing[/i] brace ( [b]}[/b] ), but up to line 7, there are no [i]opening[/i] braces. Something must be wrong... On the next line, …

Member Avatar for Ancient Dragon
-1
173
Member Avatar for Clawsy

Hmm... keeping the dictionary in an external file seems like the best approach to me. Correct me if I'm wrong. Regarding your first idea, it should work with a [icode]long int[/icode]. Correct me if I'm wrong again.

Member Avatar for Adak
0
151
Member Avatar for firoz3321

You will have to implement your own data type and the operations you want to do with them. Or, you could use a library such as [url=http://gmplib.org/]GMP[/url]. EDIT: Sorry, Auroraomega and I posted at the same time.

Member Avatar for prvnkmr449
0
4K
Member Avatar for gudads

The difference, quite obviously, is the definition of [icode]main[/icode]. In the first version, the function is defined as [icode]void main()[/icode]. Therefore, it does not return anything. Furthermore, it takes an infinite number of arguments. The second version has the function defined as [icode]int main(void)[/icode]. It returns an [icode]int[/icode] value and …

Member Avatar for gudads
0
117
Member Avatar for meer pakala

A very good first reading is [url=http://norvig.com/21-days.html]Teach Yourself Programming in 10 Years[/url].

Member Avatar for GreatWin-Win
0
233
Member Avatar for Davish

A rule of thumb around here is that you post your existing code which you have problems with, or at least a pseudo-code. The sole piece advice which can be given is to store the parts of the date in separate variables which you then print in the new format.

Member Avatar for kings_mitra
0
97
Member Avatar for Narue

[quote]Yes, this is a known bug. Unfortunately, Apple has decided to make the conscious decision of not following the CSS standard on their mobile web browsers and handling fixed positioning differently than EVERY single other web browser in the world, including Safari for the desktop and every other mobile web …

Member Avatar for creeps
0
169
Member Avatar for creeps

Hello, I've learnt a bit more C since I posted [url=http://www.daniweb.com/forums/thread302037.html]the last code review thread[/url], so I've decided to rewrite the Mystery Word application, this time using strings, pointers and pointer arithmetic, and dividing the program into files (I've only got three of those). I've also created a very basic …

Member Avatar for creeps
0
102
Member Avatar for DemiSheep

[quote]Don't excessively optimize without good reason.[/quote] This, or "[i]Premature optimization is the root of all evil.[/i]"

Member Avatar for jon.kiparsky
0
191
Member Avatar for gabblesargh

It's Objective-C, not C, and there is an extremely big difference between the two. Post it somewhere else, to a Mac/iPhone-related development forum, like [url=http://forums.macrumors.com]MacRumors[/url] or the programming-oriented [url=http://stackoverflow.com]StackOverflow[/url].

Member Avatar for peter_budo
0
187
Member Avatar for creeps

I'm going through K.N. King's introductory [i]C Programming: A Modern Approach (2e)[/i] and every time I see the code in the book, I can't help but wonder what's the better way to write your code in the following situation. Should I use the curly brackets or not, and how much …

Member Avatar for [Alpha]-0mega-
0
199
Member Avatar for taylar

Read lots of books, get involved in projects, get hands on, but, before anything, be sure you've read [url=http://norvig.com/21-days.html]Teach Yourself Programming in 10 Years[/url]. If you keep looking for information, you'll eventually know where to go from where you are.

Member Avatar for creeps
-1
128
Member Avatar for creeps

I'm trying to validate a day of the month, so that if the user enters a negative value or a value above 31, the program prints an error message and prompts for another day. The code below doesn't work as expected. Instead, it gets caught inside an infinite loop, printing …

Member Avatar for Adak
0
330
Member Avatar for daredevil786

[icode]%[/icode] is part of [i]conversion specifications[/i] such as [icode]%d[/icode] or [icode]%f[/icode]. Therefore, if you simply write [icode]%![/icode], it will be interpreted as requiring a second argument matching the data type associated to [icode]![/icode] (a so-called [i]conversion specifier[/i]). [icode]printf("Hello, World%!");[/icode] will print [icode]Hello, World![/icode]. Furthermore, it will display a formatting warning …

Member Avatar for MareoRaft
0
123
Member Avatar for daredevil786

Well... first of all, it should not come out 8, but 5. Going into your code, [icode]y[/icode] is not defined as a pointer, but it should, because what you are performing inside your code is [i]pointer arithmetic[/i]. Next, you are subtracting the address of the array, as [icode]x[/icode] actually means …

Member Avatar for pheininger
0
1K

The End.