2,384 Posted Topics
Re: 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 … | |
Re: [url]http://cboard.cprogramming.com/showthread.php?p=475679#post475679[/url] ;) | |
Re: 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]. | |
Re: 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 … | |
Re: If a prototype is not found before the function is called, then you are implicitly defining the function. | |
Re: 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]? | |
Re: You'll need to keep track of each size entered by the user. | |
Re: [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 = … | |
Re: [I]"Premature optimization is the root of all evil" --Donald Knuth[/I] Why do you ask? | |
Re: [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 … | |
Re: 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. | |
Re: [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" … | |
Re: [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.) | |
Re: 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. | |
Re: Call [url=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/wsastartup_2.asp]WSAStartup[/url] first. | |
| |
Re: [url=http://www.daniweb.com/techtalkforums/announcement8-2.html]We only give homework help to those who show effort[/url] | |
Re: [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] | |
Re: How about using [FONT=Courier New]abs[/FONT] to get the absolute value? Perhaps post an attempt. | |
Re: [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 … | |
Re: [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] | |
Re: [url]http://www.daniweb.com/techtalkforums/announcement8-2.html[/url] | |
Re: [url]http://acm.uva.es/problemset/[/url] | |
Re: 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. ![]() | |
Re: 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. | |
Re: 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. | |
Re: [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. | |
Re: 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. | |
Re: 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] | |
Re: 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 … | |
Re: [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 … | |
Re: [url]http://www.lvr.com/serport.htm[/url] | |
Re: 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]. | |
Re: 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). | |
Re: 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) { … | |
Re: [QUOTE=winbatch]as size of char* is always 4.[/QUOTE]Well, except when it isn't. :p | |
Re: >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. | |
Re: 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] | |
Re: [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.] | |
Re: 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] | |
Re: 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 … | |
Re: [QUOTE=happyshub]please can someone [COLOR=Red]give me code[/COLOR] how to reverse single link list using recurtion[/QUOTE]Show an attempt. | |
Re: 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, … | |
Re: 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); … | |
Re: 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] | |
Re: 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 … | |
Re: 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] | |
Re: 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 … |
The End.