Posts
 
Reputation
Joined
Last Seen
Ranked #360
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.2K People Reached
Favorite Forums
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
156
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
93
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
101
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
249
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
96
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
115
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
140
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
185
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
96
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
164
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
2K
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
238
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
86
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
215
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
131
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
128
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
101
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
83
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
100
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
118
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
205
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
289
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
100
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
258
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
277
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
231
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
197
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
98