2,384 Posted Topics

Member Avatar for fallendream

[QUOTE=fallendream;1151395]hey, to start with heres the backdrop; me and a friend from school have a year to create a fully working web browser and for this i think C++ would be best. heres where i need help, i have no experience with C++ and i need to learn it from …

Member Avatar for jadkins
0
570
Member Avatar for iNach

If your code is not interactive, again piping the output to a file seems like the easiest. For example, [CODE][COLOR="Green"]D:\projects\misc\c>[/COLOR]Debug\capp.exe [COLOR="Red"]> file.txt[/COLOR][/CODE]

Member Avatar for mitrmkar
0
151
Member Avatar for donelliewhyte

[QUOTE=donelliewhyte;1150721]I these contents below written to a file.I want to user to input a number and i will then scan the file to see if it matches my registration number. But in doing this i just want to get the 1001 from the first line. REGISTRATION: 1001 NAME Donellie Whyte …

Member Avatar for Adak
0
117
Member Avatar for uday.rnsit
Member Avatar for jephthah
-2
124
Member Avatar for jBat

Does the compiler know what a [ICODE]struct argp_state[/ICODE] is? Or a [ICODE]struct arguments[/ICODE]?

Member Avatar for jBat
0
134
Member Avatar for Kikazaru

[QUOTE=Ancient Dragon;1149277]Whether or not there is computational time will be compiler dependent. Assuming you have a good optimizing compiler and do NOT compile the program for debug, the compiler will may or may not toss out any storage for constants and keep the value in registers. That, however, is pretty …

Member Avatar for vijayan121
0
3K
Member Avatar for johndoe444

On the stack, 9 MB might be asking a bit much. Either try a variable with static duration (a global) or use dynamic allocation (prefer the latter).

Member Avatar for Salem
0
172
Member Avatar for D4n1sD
Member Avatar for jimJohnson

[url=http://www.daniweb.com/techtalkforums/post155265-18.html]Avoid Loop Control Using eof()[/url]

Member Avatar for jonsca
0
248
Member Avatar for Don_k

[QUOTE=Don_k;1147555] 2. copies array1 into a variable called array2, converting each element of array1 to UPPER CASE[/QUOTE] Just use [ICODE]toupper[/ICODE] on all characters in the text. Like: [CODE] int i; for ( i = 0; array1[i]; ++i ) { [COLOR="Red"]array2[i] = toupper(array1[i]);[/COLOR] } array2[i] = '\0';[/CODE]

Member Avatar for Dave Sinkula
0
122
Member Avatar for EvilNerd

[QUOTE=EvilNerd;1148673]My problem is when i try to include the function [B]funcString[/B] in my code and try to built it , i get this errors:[QUOTE]error C2065: 'ch' : undeclared identifier[/QUOTE][/QUOTE] That message is soooo self-explanatory. Look at the location of the error: where in funcString is 'ch' declared? To 'fix' an …

Member Avatar for EvilNerd
0
160
Member Avatar for BeyondTheEye

[URL="http://en.wikipedia.org/wiki/Serial_port"]Serial port[/URL], [URL="http://en.wikipedia.org/wiki/Universal_asynchronous_receiver/transmitter"]UART[/URL]

Member Avatar for BeyondTheEye
0
264
Member Avatar for logicalguy

[QUOTE=Adak;1147277]That GD casting on the return from the compare function, is one reason I dislike C's qsort. Sure, it's nice for different kinds of data, but damn it, people sort two things, a great deal - strings and numbers. It doesn't have to be that much of a PITA. (By …

Member Avatar for Dave Sinkula
0
5K
Member Avatar for Luks

Use * to indicate multiplication. [CODE]if (gender == "Male"){ BFat = 495/(1.0324-.19077[COLOR="Red"][B]*[/B][/COLOR](log(abdomen-neck))+.15456[COLOR="Red"][B]*[/B][/COLOR](log(height)))-450; // THE ERROR IS HERE } else if (gender == "Female"){ BFat = 495/(1.29579-.35004[COLOR="Red"][B]*[/B][/COLOR](log(abdomen+hip-neck))+.22100[COLOR="Red"][B]*[/B][/COLOR](log(height)))-450; // THE ERROR IS HEAR } [/CODE]

Member Avatar for Luks
-2
221
Member Avatar for lionaneesh
Member Avatar for lionaneesh
0
194
Member Avatar for johndoe444

I doubt the problem is fclose. Of course it would be a good idea if fp is NULL not to continue. Do you have long input lines? Is the problem really elsewhere in the code you didn't post? Can you post enough of a trimmed but complete bit of code …

Member Avatar for Adak
0
185
Member Avatar for dibbieshir

All that gets() and clrscr() stuff makes me want to post [URL="http://www.daniweb.com/tutorials/tutorial45806.html"]this[/URL] so you might take user input in a better way.

Member Avatar for Dave Sinkula
0
234
Member Avatar for happygeek

[QUOTE=happygeek;1113355]OK then, just for fun, can you remember the very first thing that you posted on DaniWeb? [/quote] Remember it? Nope. [url]http://www.daniweb.com/forums/post27067.html#post27067[/url] [QUOTE=happygeek;1113355]Go on, tell us the when and what, even if it was really embarrassing :)[/quote] I didn't start out as an "asker". ;) I think Cprog was down …

Member Avatar for Dave Sinkula
0
524
Member Avatar for Programmer88

Welcome. Have you met [url=http://www.google.com/search?q=binary+decimal]Google[/url]? Please peruse the [url=http://www.daniweb.com/techtalkforums/announcement.php?f=8&announcementid=2]announcement[/url].

Member Avatar for pampres
-2
197
Member Avatar for axed

[QUOTE=axed;1146192]1.) So from this it seems that heap memory is a part of the executable. It would increase the size of the executable as more memory is allocated(using new, malloc) while the program is executing. Whereas stack memory is in the RAM and doesn't change affect the size of the …

Member Avatar for axed
0
159
Member Avatar for johndoe444

[QUOTE=johndoe444;1146781]I am sick of segmentation faults. This is the last straw. How to tame this ferocious wild beast? For small programs it can be debugged. But when dealing with large programs such as implementing a b-tree with thousands of pointers it is a nightmare to pinpoint the location of segmentation …

Member Avatar for thomas_naveen
0
126
Member Avatar for prakashjoshi010

[QUOTE=prakashjoshi010;1146791]__cdecl is calling convention. which is default calling convention for c & c++. others are: __cdecl __stdcall __fastcall ... I want to mention calling convention in function declaration.[/QUOTE] Such things are not standard C or C++, they are language extensions. They may or may not have any meaning for a …

Member Avatar for Dave Sinkula
0
133
Member Avatar for richman0829

Lots of little bits, I'll highlight a few. [CODE]#include <iostream> using namespace std; const int SIZE = 5; [COLOR="Red"]int*[/COLOR] newArrayMaker(); int main () { [COLOR="Red"]int *[/COLOR]newArray = newArrayMaker(); cout << "The new array has these contents: "; for ( int i = 0; i < SIZE; i++ ) cout << …

Member Avatar for richman0829
0
189
Member Avatar for richman0829

[QUOTE=richman0829;1146448]What I can't understand is why x is out of scope. The text I'm using says “vars having local or block scope may be used only in the part of the program between their definition and the block’s closing brace” - so if I declare x at the start of …

Member Avatar for richman0829
0
124
Member Avatar for clutchkiller

[QUOTE=clutchkiller;1146251]For now? Are they fixing this currently?[/QUOTE]Don't hold your breath. [url]http://www.parashift.com/c++-faq-lite/templates.html#faq-35.12[/url]

Member Avatar for StuXYZ
0
121
Member Avatar for sunlitdays

How about calculating the end in seconds and then converting to h:m:s? [edit]As for the formatting, I prefer printf, but you can produce zero-padding and fixed width other ways.

Member Avatar for WaltP
0
167
Member Avatar for katwalatapan
Member Avatar for Dave Sinkula
0
149
Member Avatar for sexyzebra19

Isn't row- or column-major done like this? [CODE]#include <stdio.h> void col_major(int *data, int rows, int cols) { size_t i, j; puts("column major:"); for ( i = 0; i < rows; ++i ) { for ( j = 0; j < cols; ++j ) { [COLOR="Red"]int index = i * cols …

Member Avatar for Dave Sinkula
0
146
Member Avatar for Cristofor

[QUOTE=Cristofor;1145182]For example, If I want to use windows.h and Visual studio 2008 does not have this headfile. So what I do is to download it from google and then paste it to C:\Program Files\Microsoft Visual Studio 9.0\VC\include. However, I know this does not work. I want to ask how to …

Member Avatar for Dave Sinkula
0
190
Member Avatar for Swiftle

[QUOTE=Swiftle;1144309]The file I'm using has 18, A minor annoyance that it will do one more loop and store an empty keyword. For example if the the 18th line in my file reads vector it will then create a 19th entry which has an empty keyword.[/QUOTE]That's pretty much expected behavior. [url=http://www.daniweb.com/techtalkforums/post155265-18.html]Avoid …

Member Avatar for mitrmkar
0
143
Member Avatar for alma27534
Member Avatar for KRal
Member Avatar for COKEDUDE

[QUOTE=COKEDUDE;1144251]The only two ways I know of to break out of a loop is with a break statement or return 0, but in this case neither will work. I have a void statement so can't use a return statement [/QUOTE] You can use a return from a void function. [QUOTE=COKEDUDE;1144251]and …

Member Avatar for abhimanipal
0
145
Member Avatar for e40thrilla

[CODE]while (!fin.eof())[/CODE] Avoid loop control using eof(). [CODE]while ( fin >> ValueRead )[/CODE] I get deja vu from saying this. [url]http://www.daniweb.com/techtalkforums/post155265-18.html[/url]

Member Avatar for mitrmkar
0
1K
Member Avatar for correaj

[url]http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.2[/url]

Member Avatar for correaj
0
874
Member Avatar for hey joe
Member Avatar for logicmonster

Don't continue after line 58 if you're done. Perhaps add another if() statement to see if you ought do the do...while loop.

Member Avatar for logicmonster
0
116
Member Avatar for rjani1

[QUOTE=rjani1;1143528]I have tried that but this does not produce an output on the screen. I always seem to have to use the newline character (\n) in order to get anything.[/QUOTE] Try [ICODE]\r[/ICODE] in your printf, and follow that with [ICODE]fflush(stdout);[/ICODE]. (If you continue with this approach.)

Member Avatar for rjani1
0
1K
Member Avatar for Tango2010

A wee bit further down the road, perhaps, but... [URL="http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1046380353&id=1044780608"]Accessing a directory and all the files within it[/URL] [URL="http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1047077601&id=1045780608"]*nix Specific > Working with files and directories[/URL]

Member Avatar for Salem
0
209
Member Avatar for roll_in_k

[QUOTE=roll_in_k;1140836]So in the above example suppose that we have more than one double pointers in the function.. and we can t use return or gloabal variables[/QUOTE] Why the restriction about using return? I would tend to prefer something with this sort of an interface: [CODE]T** array2d_create(int rows, int cols); void …

Member Avatar for roll_in_k
0
350
Member Avatar for Excizted

Assuming your data is in structures, fread and fwrite them. But... [QUOTE][URL="http://c-faq.com/misc/binaryfiles.html"]Q: How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?[/URL] A: The most portable solution is to use text files (usually ASCII), written with fprintf …

Member Avatar for Dave Sinkula
0
125
Member Avatar for Stack Overflow
Member Avatar for Ancient Dragon
0
2K
Member Avatar for bogenbroom

Don't repeat your filename validation with a duplicate section of code after the first check. Use the first check as the only check.

Member Avatar for bogenbroom
0
1K
Member Avatar for turrence27
Member Avatar for turrence27
0
2K
Member Avatar for miskeen

[CODE] memset([COLOR="Red"]pValid[/COLOR], 1, 10 * sizeof (short)); for ( i = 0; i < 10; i++ ) printf("%d ", [COLOR="Green"]pValid[i][/COLOR]); // the seg fault is here [/CODE]

Member Avatar for Dave Sinkula
0
59
Member Avatar for hwlibra083

If you want your array to hold strings, you'll need another dimension and need to allocate space for the strings. Or do you want it to be a 2D array of chars? Or ints?

Member Avatar for hwlibra083
0
505
Member Avatar for VernonDozier

[QUOTE=VernonDozier;1142184]I want to be able to call a function which accepts a variable number of parameters, which then calls another function and passes it those parameters.[/QUOTE] Is this the question you are asking? [URL="http://c-faq.com/varargs/handoff.html"]Q: How can I write a function which takes a variable number of arguments and passes them …

Member Avatar for VernonDozier
1
232
Member Avatar for cyberguy007

An array a[99] has 99 elements, indexed from a[0] to a[98]. You are trying to index this array from a[1] to a[99]. In your lone printf, drop the &.

Member Avatar for Dave Sinkula
0
76
Member Avatar for anthony5557

[QUOTE=anthony5557;1141804]Mr. Walt there are 24 different errors how would you like me to list them.[/QUOTE] Yes. It's usually just a simple copy-and-paste that takes mere seconds. [QUOTE]main.cpp In file included from main.cpp:7: DayConverter.h:8: error: `Class' does not name a type DayConverter.h:19: error: extra `;' DayConverter.h:21: error: `DayConverter' has not been …

Member Avatar for Fbody
0
208
Member Avatar for sblass92

[ICODE]#include <ostream>[/ICODE] instead of [ICODE]#include <sstream>[/ICODE] in [ICODE]particle.h[/ICODE] and/or [ICODE]particle.cpp[/ICODE]. [CODE]ostream& operator<<(ostream& outs, const particle& x){ outs << [COLOR="red"]x.[/COLOR]Xcomp << " " << [COLOR="red"]x.[/COLOR]Ycomp << " " << [COLOR="red"]x.[/COLOR]Zcomp << " "; return(outs); }[/CODE] [CODE]#include "particle.h" [COLOR="red"]#include <iostream> using std::cout;[/COLOR] int main() { particle x; cout << x; }[/CODE]

Member Avatar for sblass92
0
181

The End.