2,384 Posted Topics

Member Avatar for freemind

First, there is a difference between [FONT=Courier New]char* const str[/FONT] and [FONT=Courier New]const char* str[/FONT]. In [FONT=Courier New]char* const str[/FONT], the pointer may not be modified, but what it points to may be. But this means you can't increment the pointer. A [FONT=Courier New]const char* str[/FONT] means that the pointer …

Member Avatar for freemind
0
104
Member Avatar for akshayabc

[url]http://cboard.cprogramming.com/showthread.php?p=475679#post475679[/url] ;)

Member Avatar for akshayabc
0
140
Member Avatar for mav1

I only took a quick look, but it sounds like the old [I]newline left over in the input buffer[/I] thing: you type [FONT=Courier New]Y<cr>[/FONT]; you grab the [FONT=Courier New]'Y'[/FONT] and the next time through you end up getting the [FONT=Courier New]'\n'[/FONT], which is not a [FONT=Courier New]'Y'[/FONT].

Member Avatar for varunpuri
0
178
Member Avatar for JoBe

A "compiler" is generally a couple of different tools sandwiched together. There may be a preprocessor, the compiler proper, a linker and maybe some others. The preprocessor, for example, may process [FONT=Courier New]#define[/FONT]s and [FONT=Courier New]#include[/FONT]s and strip out comments. Then this raw code is fed to the compiler proper …

Member Avatar for JoBe
0
240
Member Avatar for dile

If a prototype is not found before the function is called, then you are implicitly defining the function.

Member Avatar for oboler
0
163
Member Avatar for shre86

Anything useful in [URL=http://www.ecst.csuchico.edu/~beej/guide/net/html/]Beej[/URL] or the [url=http://tangentsoft.net/wskfaq/]WinSock FAQ[/url]?

Member Avatar for Dave Sinkula
0
113
Member Avatar for JoBe
Member Avatar for JoBe
0
585
Member Avatar for dello

[QUOTE=dello]but the average only gives the correct value if there are 12 entries - so i need to know how to get it automatically divide by the number of entries and not by 12 each time...[/QUOTE]The basics...[code]#include <stdio.h> int main(void) { static const char filename[] = "data.txt"; FILE *file = …

Member Avatar for BruceWilson512
0
263
Member Avatar for johnson9000
Member Avatar for johnson9000
0
149
Member Avatar for amna zafar
Member Avatar for akshayabc

[QUOTE=akshayabc]Q1 In C, characters have ASCII codes in range 0-255. How can we print characters having ASCII code from 128-255. printf("%c",(unsigned)129); //it will still print the char having ASCII -127[/QUOTE]ASCII is a 7-bit code, ranging from 0 - 127. Extended ASCII may be different here or there. The character you …

Member Avatar for Dave Sinkula
0
131
Member Avatar for oRg

Make the arrays big enough for the null terminator, and null terminate each. [url=http://www.daniweb.com/techtalkforums/post109572-12.html]This[/url] might also be of interest.

Member Avatar for oRg
0
440
Member Avatar for NejiHyuuga

[QUOTE=NejiHyuuga]I need help organizing my program.[/QUOTE]Do you mean you want the output to be nicely formatted? Use some maniuplators.[code]#include <[COLOR=Magenta]iostream[/COLOR]> [COLOR=Blue]#include <iomanip>[/COLOR] #include <[COLOR=Magenta]cmath[/COLOR]> [COLOR=Magenta]using namespace std;[/COLOR] [COLOR=Magenta]int[/COLOR] main() { double radius = 0, degree = 0; cout << [COLOR=Blue]setw(7) <<[/COLOR] "Degrees" << [COLOR=Blue]setw(20) << [/COLOR]"sin" << [COLOR=Blue]setw(20) <<[/COLOR] "cos" …

Member Avatar for Dave Sinkula
0
141
Member Avatar for harshchandra

[quote]Everything is working well and good[/quote]I can't even get it to compile.[code] [COLOR=Red]long float[/COLOR] amount;[/code]Using types before they are defined. And I don't have [FONT=Courier New]graphics.h[/FONT]. (That's the joy of nonstandard code -- fewer folks who can help.)

Member Avatar for harshchandra
0
150
Member Avatar for karimkabbani

I'm merging all these threads. Please don't bump them like this. Show an attempt rather than waiting for someone else to do it for you.

Member Avatar for Dave Sinkula
0
230
Member Avatar for numerouno543

Call [url=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/wsastartup_2.asp]WSAStartup[/url] first.

Member Avatar for numerouno543
0
326
Member Avatar for komalac
Member Avatar for limu

[url=http://www.daniweb.com/techtalkforums/announcement8-2.html]We only give homework help to those who show effort[/url]

Member Avatar for Dave Sinkula
0
64
Member Avatar for loki73

[quote] -The program '[932] trst.exe: Native' has exited with code 0 (0x0).[/quote]It did run. It ran successfully. Then it exited. [url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1043803465&id=1043284385[/url]

Member Avatar for Dave Sinkula
0
229
Member Avatar for petethepop

How about using [FONT=Courier New]abs[/FONT] to get the absolute value? Perhaps post an attempt.

Member Avatar for petethepop
0
234
Member Avatar for johnroach1985

[quote=johnroach1985]Hi i am re-studying C.So I just wanted to do a simple calculator program.I am using dev-c++ anyways the code is below please help.[/quote]It's easier to provide answers when you provide questions. You may want to take a look at a way to [url=http://www.daniweb.com/code/snippet278.html]Read a Line of Text from the …

Member Avatar for johnroach1985
0
198
Member Avatar for Rodan

[QUOTE=Rodan]I need to learn things in/what code is the right one to use:[code]system("CLS");[/code] or [code]clrscr();[/code], etc.[/QUOTE][url]http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1031963460&id=1043284385[/url]

Member Avatar for Dave Sinkula
0
199
Member Avatar for nyyrule
Member Avatar for crestaldin
Member Avatar for Narue

I prefer them separate once a certain critical mass is reached. Your points [post=118579]here[/post] summarize things well. As long as the moderators can separate the two languages on an individual basis when necessary, there is less need for separation in the near future.

Member Avatar for Electrohead
0
609
Member Avatar for cuperman

Look into signals (an [url=http://cboard.cprogramming.com/showthread.php?p=347013#post347013]example[/url]). [URL=http://www.rt.com/man/sscanf.3.html][FONT=Courier New]sscanf[/FONT][/URL] - but your compiler should have this documentation already.

Member Avatar for Dave Sinkula
0
86
Member Avatar for sadeolah

Perhaps there is a [url=http://www.daniweb.com/code/snippet141.html]snippet[/url] or [url=http://www.daniweb.com/code/snippet109.html]two[/url] in the [URL=http://www.daniweb.com/code/c.html]Code Snippets[/URL] section.

Member Avatar for Dave Sinkula
0
93
Member Avatar for Robert G

[QUOTE=Robert G]I have no idea what I'm doing.[/QUOTE]And we can't your actual code. Try posting it within code tags.

Member Avatar for Dave Sinkula
0
83
Member Avatar for rkarimi

The best answer is to use a makefile/IDE. If you don't want to, yes, it is a lot of editing. That is precisely why you generally don't specify a path on the [FONT=Courier New]#include[/FONT] line and instead point the compiler at where to look.

Member Avatar for Dave Sinkula
0
88
Member Avatar for evilsilver

Arrays are indexed from 0 to N-1, not 1 to N. The usual idiom is like this. [code]for ( i = [COLOR=Blue]0[/COLOR]; i [COLOR=Blue]<[/COLOR] N; ++i )[/code]

Member Avatar for Dave Sinkula
0
82
Member Avatar for Merrissey

One way:[code]#include <stdio.h> int main(void) { const char text[] = "097102099105110"; int i, value[5]; if ( sscanf(text, "%3d%3d%3d%3d%3d", &value[0], &value[1], &value[2], &value[3], &value[4]) == 5 ) { for ( i = 0; i < 5; ++i ) { printf("value[%d] = %d\n", i, value[i]); } } return 0; } /* my …

Member Avatar for Dave Sinkula
0
242
Member Avatar for Zackery

[QUOTE=Zackery]Ok so I have this program and Im using 2 functions that both use "buffer" to move the images to the front screen. Well I used create_bitmap(800,600) to make the buffer, but im using that in both functions so, they both are diffrent buffers! So when I run the program …

Member Avatar for Dave Sinkula
0
136
Member Avatar for Blip
Member Avatar for Narue
Member Avatar for rkarimi

Consider [FONT=Courier New]malloc[/FONT]/[FONT=Courier New]free[/FONT] to create the array. Functions that use the array should take a pointer to [FONT=Courier New]const[/FONT].

Member Avatar for Dave Sinkula
0
107
Member Avatar for myprecious

Post a sample of the data file and a minimal code that attempts to read the data (for example: the structure and array definitions, your read routine, and a call of the read routine from main).

Member Avatar for myprecious
1
118
Member Avatar for stage

Looks like bits to me again. [code]#include <stdio.h> void foo(int value) { int i; printf("%d : ", value); for ( i = 0; i < 8; ++i ) { if ( value & (1 << i) ) { printf("%d ", i + 1); } } putchar('\n'); } int main(void) { …

Member Avatar for stage
0
98
Member Avatar for aaron_tan

[QUOTE=winbatch]as size of char* is always 4.[/QUOTE]Well, except when it isn't. :p

Member Avatar for aaron_tan
0
136
Member Avatar for nyyrule

>and then it's supposed to calculate the average which I can't figure out how The average is the sum divided by the total number of values that contributed to the sum.

Member Avatar for Dave Sinkula
0
97
Member Avatar for winbatch

Isn't the error related to trying to create a string from a long value? This may not be the best fix, but FWIW. [code] [COLOR=Blue]ostringstream i; // ;) i << source;[/COLOR] istringstream o; o.str([COLOR=Blue]i.str()[/COLOR]);[/code]

Member Avatar for winbatch
0
182
Member Avatar for winbatch

[code]string f = [COLOR=Red]"F" + "F"[/COLOR];[/code]The last one is [FONT=Courier New]operator+[/FONT] for [FONT=Courier New]const char *[/FONT], like it says, not for strings. You would be trying to overload a builtin, not the string. [Or something to this affect, I believe. The operation on the right happens before the assignment.]

Member Avatar for Dogtree
0
79
Member Avatar for white_eyez

Hmm. Something like this? [code]credit_limit = 400; credit_total = 0; balance = 0; charges_remaining = [I]something[/I]; while ( charges_remaining ) { charges = get_charges(); credits = get_credits(); balance = balance + charges - credit if ( credit_total > credit_limit ) { error_message(); } charges = charges - 1; }[/code]

Member Avatar for Dave Sinkula
0
81
Member Avatar for aaron_tan

I had been messing with this a bit from the original, but I wasn't exactly sure of what it was the VB was doing. Could you provide an example of what the function is intended to do? Something along the lines of... [quote][Background information about function usage.] The function[code]DWORD RegGetStringValue(HKEY …

Member Avatar for Dave Sinkula
0
163
Member Avatar for happyshub

[QUOTE=happyshub]please can someone [COLOR=Red]give me code[/COLOR] how to reverse single link list using recurtion[/QUOTE]Show an attempt.

Member Avatar for happyshub
0
213
Member Avatar for harshchandra

There functions in [FONT=Courier New]<time.h>[/FONT] such as [FONT=Courier New]time[/FONT], [FONT=Courier New]localtime[/FONT], and [FONT=Courier New]strftime[/FONT]. [code]#include <stdio.h> #include <time.h> int main(void) { time_t now; if ( time(&now) != (time_t)(-1) ) { struct tm *mytime = localtime(&now); if ( mytime ) { char buffer [ 32 ]; if ( strftime(buffer, sizeof buffer, …

Member Avatar for Dave Sinkula
0
93
Member Avatar for stage

A different approach...[code]#include <stdio.h> #include <string.h> #include <stdlib.h> int main(int argc, char *argv[]) { int relay = 0; int i; for ( i = 0; argv[1][i]; ++i ) { int x = 1 << (argv[1][i] - '1 '); printf("x = %d\n", x); relay += x; } printf("relay = %d\n", relay); …

Member Avatar for stage
0
10K
Member Avatar for student113

I'd say [url=http://www.google.com]Google[/url] is a good place to start. You've used several keywords in your post, I'd run them past Google. Perhaps the links it turns up will help you find other terms that will further help you narrow your search. [edit][url=http://www.google.com/search?q=robot+AI+algorithm+search+tree+learning]Example[/url]. [edit]There is also this: [url]http://www.aihorizon.com/[/url]

Member Avatar for Dani
0
168
Member Avatar for amt_muk

In source code, the sequence [FONT=Courier New]\n[/FONT] means a newline -- the compiler does the translation. In an interactive program, the sequence [FONT=Courier New]\n[/FONT] means the character [FONT=Courier New]\[/FONT] followed by the character [FONT=Courier New]n[/FONT]. Hitting the enter key in an interactive program puts the newline character in the input …

Member Avatar for Dave Sinkula
0
101
Member Avatar for floyd

This does not try to read, it just moves to someplace in the file:[code]//try to read fist entry myFile.seekg ( sales.vendors[sales.numVendors].name * sizeof (annualSalesData ), ios::end );[/code] Is [FONT=Courier New]sales.numVendors[/FONT] initialized here?[code]myFile >> sales.vendors[sales.numVendors].name; [/code]

Member Avatar for Dave Sinkula
0
123
Member Avatar for rkarimi

I don't know that I fully understand your question. If you want to modify a pointer, in C you would pass a pointer to a pointer.[code]typedef float MYFLOAT; // or Called Standalone #define MYPRINT printf #define MYMAIN main #include <string> #include <cstdio> #include <cctype> #include <stdio.h> #include <stdlib.h> void MAKE(MYFLOAT …

Member Avatar for amt_muk
0
128

The End.