2,384 Posted Topics
Re: [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 … | |
Re: 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] | |
Re: [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 … | |
Re: [url]http://catb.org/~esr/faqs/smart-questions.html[/url] | |
Re: Does the compiler know what a [ICODE]struct argp_state[/ICODE] is? Or a [ICODE]struct arguments[/ICODE]? | |
Re: [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 … | |
Re: 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). | |
Re: [url=http://www.daniweb.com/techtalkforums/post155265-18.html]Avoid Loop Control Using eof()[/url] | |
Re: [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] | |
Re: [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 … | |
Re: [URL="http://en.wikipedia.org/wiki/Serial_port"]Serial port[/URL], [URL="http://en.wikipedia.org/wiki/Universal_asynchronous_receiver/transmitter"]UART[/URL] | |
Re: [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 … | |
Re: 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] | |
Re: Concatenate and compare. Look up the man page for more function details. | |
Re: 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 … | |
Re: 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. | |
Re: [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 … | |
Re: 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]. | |
Re: [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 … | |
Re: [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 … | |
Re: [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 … | |
Re: 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 << … | |
Re: [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 … | |
Re: [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] | |
Re: 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. | |
Re: What is your compiler/build target? Have you tried making the array a global? | |
Re: 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 … | |
Re: [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 … | |
Re: [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 … | |
| |
| |
Re: [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 … | |
Re: [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] | |
Re: [url]http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.2[/url] | |
Re: 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. | |
Re: [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.) | |
Re: 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] | |
Re: [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 … | |
Re: 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 … | |
Re: strdup is nonstandard. Your realloc idiom is one to avoid. | |
Re: Don't repeat your filename validation with a duplicate section of code after the first check. Use the first check as the only check. | |
Re: cardNumber.Length ? An integer doesn't have member elements. | |
Re: [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] | |
Re: 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? | |
Re: [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 … | |
Re: 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 &. | |
Re: [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 … | |
Re: [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] |
The End.