2,384 Posted Topics

Member Avatar for johndoe444

[url]http://c-faq.com/aryptr/ary2dfunc3.html[/url] [url]http://c-faq.com/aryptr/index.html[/url]

Member Avatar for Dave Sinkula
0
115
Member Avatar for daudiam

Maybe the answer to the interview question is that none is faster than any other? Or that the answer is outside of C itself?

Member Avatar for nezachem
0
637
Member Avatar for daveoffy

Make the string separately using sprintf or the like. [edit]Make sure your destination has enough room for the text you want in it.

Member Avatar for daveoffy
0
161
Member Avatar for Excizted

[CODE]#include <iostream> using std::cout; using std::hex; #include <string> using std::string; #include <sstream> using std::ostringstream; #define VERSION_MAJOR 1 #define VERSION_MINOR 1 #define VERSION_PATCH 2 #define VERSION ((VERSION_MAJOR << 16) | (VERSION_MINOR << 8) | VERSION_PATCH) int main() { int version = VERSION; cout << "version = " << hex << version …

Member Avatar for Excizted
0
149
Member Avatar for sknake

[QUOTE=cscgal;1075897]Well then be more vocal about which features you use and how you use them. :)[/QUOTE] It's hard to read your mind about what you're going to get rid of next. :icon_wink: [QUOTE=cscgal;1075897] i.e. When you first visit DaniWeb, how do you begin your visit?[/QUOTE] UserCP, which used to give …

Member Avatar for sknake
2
430
Member Avatar for Dave Sinkula

This is a [inlinecode]strtol[/inlinecode] version of [url=http://www.daniweb.com/code/snippet353.html] Read an Integer from the User, Part 2[/url].

Member Avatar for anthonytan
0
551
Member Avatar for anthonytan

[CODE] do { fputs("Enter an integer[COLOR="Red"] (0-100)[/COLOR]: ", stdout); fflush(stdout); } while ( !mygeti(&value)[COLOR="red"] || value < 0 || value > 100[/COLOR] );[/CODE]

Member Avatar for anthonytan
0
131
Member Avatar for tech291083

Quantity is not always the best criteria for evaluating sources of information. You might also want to consider: [url]http://cboard.cprogramming.com/[/url] Not a forum, per se, but I'd also throw in this (an excellent resource for searching): [url]http://groups.google.com/group/comp.lang.c++/topics[/url]

Member Avatar for tech291083
0
198
Member Avatar for MAV_DevWantaB

[QUOTE=MAV_DevWantaB;1082924]I believe it is working correctly but I think I have my Understanding of bits backWards....... :hair: [/QUOTE] When you print the bits of the number, I would presume you want to print MSB to LSB so it reads from left to right. By printing from LSB to MSB, it …

Member Avatar for MAV_DevWantaB
0
219
Member Avatar for Happy Family

[QUOTE=Happy Family;1083111]Hi every one. it is my solution. if it is false, reply. using Turbo C[/QUOTE]Pretty ugly, and it doesn't need to be nonstandard. Was this an assignment to do this without using the standard library?

Member Avatar for Dave Sinkula
-1
96
Member Avatar for rt.arti

Line 42? How about posting a small but compilable snippet that demonstrates the problem?

Member Avatar for Dave Sinkula
0
96
Member Avatar for The-IT

[QUOTE=The-IT;1082808]I created a script that uses a variable in a for-loop, that was defined before the loop its self. I get this error: [code]skilz.c: In function ‘main’: skilz.c:16: [COLOR="Red"]error: ‘prog’ undeclared [/COLOR](first use in this function) skilz.c:16: error: (Each undeclared identifier is reported only once skilz.c:16: error: for each function …

Member Avatar for Dave Sinkula
0
143
Member Avatar for cthoes

In the first one, you respond [iCODE][COLOR="Red"][I]name[/I]\n[/COLOR][/iCODE] (where the [iCODE]\n[/iCODE] is the result of pressing the [enter] key. The [ICODE]%s[/ICODE] with [ICODE]scanf[/ICODE] stops at whitespace, which [iCODE]\n[/iCODE] is, so that is leftover in the input buffer. This will immediately satisfy the subsequent call to [ICODE]getchar[/ICODE]. Since [ICODE]getchar[/ICODE] returns an [ICODE]int[/ICODE], …

Member Avatar for cthoes
0
101
Member Avatar for johndoe444

[url]http://c-faq.com/varargs/index.html[/url] [url]http://c-faq.com/varargs/vprintf.html[/url] [url]http://c-faq.com/varargs/handoff.html[/url]

Member Avatar for Dave Sinkula
0
114
Member Avatar for qwertymk

I don't know that you've found your answer yet:[code]#include <iostream> using namespace std; class myclass { public: myclass() { cout << "Hi, I'm the constuctor" << endl; } }; int main() { myclass *m; m = (myclass*) malloc (sizeof(myclass)); [COLOR="Red"]m = &(myclass());[/COLOR] return 0; }[/code][QUOTE]main.cpp:Error 50: Attempted to take the …

Member Avatar for Narue
0
147
Member Avatar for Agni
Member Avatar for Dave Sinkula
0
153
Member Avatar for s8498

[QUOTE=s8498;1079764]I still can't figure out how to read 24 lines at a time :( Or where I should put the if statement and what that would do and how to link it all together? *** Oh, I also need to figure out how to number each line of the text …

Member Avatar for UberJoker
0
2K
Member Avatar for Iam3R
Member Avatar for Iam3R
Member Avatar for William Hemsworth

And is [url]http://www.daniweb.com/forums/thread245380.html[/url] related?

Member Avatar for William Hemsworth
0
185
Member Avatar for axed

Why do you cast away the constness? [code]char * filePathName = (char *)(filePathNameString.c_str()); TAQTradesReader taq( filePathName );[/code] Surely you are making no attempt to modify the text that you are passing?

Member Avatar for thelamb
0
130
Member Avatar for dennis.d.elston

[QUOTE=dennis.d.elston;1078879]I am trying to write a funtion that will return the value of 1 if its string argument is a palindrome. I have started but am unsure if it is correct. Could someone please take a look and point me in the right direction? Thanks [CODE]#include <string.h> Int palindrome (const …

Member Avatar for mrnutty
0
126
Member Avatar for Lilal

If it's a text file, and apparently PPM is [edit][URL="http://en.wikipedia.org/wiki/Portable_pixmap"]or is it?[/URL][/edit], don't mess with binary mode. Also, don't write "little integers" that happen to be characters as characters -- that is, don't use fputc; write these little integers as integers using *printf and read with *scanf.

Member Avatar for Lilal
0
298
Member Avatar for Derp2000

[QUOTE=Derp2000;1078499]Thank you very much. :) I'm having a problem where it ignores the fgets in the first loop iteration but I finally feel like I'm getting somewhere with this.[/QUOTE] That's because you didn't clean up after this: [CODE]scanf("%i", &numNames);[/CODE] The newline is left over.

Member Avatar for Derp2000
1
125
Member Avatar for progag

[QUOTE=progag;1078662]can anyone write the full program ?[/QUOTE]You're supposed to show an attempt, and corrections and suggestions would then be offered. [QUOTE=progag;1078679]11 ERRORS[/QUOTE]How rude. You make no attempt and then complain about a gift? Why don't you take a pop at correcting the errors and start trying to do your own …

Member Avatar for Dave Sinkula
0
96
Member Avatar for anonymous alias

[QUOTE=Ancient Dragon;1076607]I assume she has a lot of other higher priority things to do than devote a lot of time/effort to something like this.[/QUOTE] [url]http://www.daniweb.com/twitter/tweet246053.html[/url] :icon_razz:

Member Avatar for diafol
-2
414
Member Avatar for Stefano Mtangoo

1. What is your favorite IDE [B]SlickEdit[/B] 2. What is your favorite GUI library [B]N/A, OpenGL if it weren't N/A[/B] 3. What is library that you often use? [B]Standard libraries; libXML, zlib, dabbling in libCurl in a far lesser extent[/B] 4. Anything related? [B]I recommend using Lint[/B]

Member Avatar for Lawand
0
139
Member Avatar for Placinta

To change the value of an object in a called function, you generally pass a pointer to the object. [CODE]#include <stdio.h> #include <stdlib.h> void allocate_matrix([COLOR="Red"]int ***[/COLOR]table, int rows, int columns); int main() { [COLOR="Green"]int i, j;[/COLOR] int **table = NULL; allocate_matrix([COLOR="Red"]&[/COLOR]table, 3, 3); [COLOR="Green"]for ( i = 0; i < …

Member Avatar for Placinta
0
138
Member Avatar for Stefano Mtangoo

[QUOTE=evstevemd;1076283]I see alot of libraries written in C and I like C++ OOP way. How can I use a given C library functions in C++?[/QUOTE] [url]http://parashift.com/c++-faq-lite/mixing-c-and-cpp.html[/url]

Member Avatar for Stefano Mtangoo
0
176
Member Avatar for raghuhr84

[QUOTE=xavier666;1070819]And can you provide me a link where I can find the problems associated with [icode]scanf()[/icode][/quote] [url]http://www.c-faq.com/stdio/scanfhang.html[/url] [url]http://www.c-faq.com/stdio/scanfinterlace.html[/url] [url]http://www.c-faq.com/stdio/scanfc.html[/url] [url]http://www.c-faq.com/stdio/scanfjam.html[/url] [url]http://www.c-faq.com/stdio/scanfprobs.html[/url] [QUOTE=xavier666;1070819]and [icode]fflush()[/icode][/QUOTE] [url]http://www.c-faq.com/stdio/stdinflush.html[/url] [url]http://www.c-faq.com/stdio/stdinflush2.html[/url] ;)

Member Avatar for Dave Sinkula
1
689
Member Avatar for Dave Sinkula

I didn't notice until recently that another post of mine got munched by the latest "upgrade". In [URL="http://www.daniweb.com/tutorials/tutorial45806.html"]this[/URL], I'd had a link in the comments of the code. Oh, it was once simple and dandy looking, but now it has some pre-processing done on it and looks like crap. Since …

Member Avatar for lllllIllIlllI
0
321
Member Avatar for hassedo

I would definitely think about rewriting that ... thing ... using arrays. But here: [CODE]double computation([COLOR="Red"]matrix [/COLOR]k, int mA, int nA, int [COLOR="Red"]matrix[/COLOR], int m1, int m2, int m3, int m4, int m5, int m6, int m7, int m8, int m9, int m10, int n1,int n2,int n3,int n4,int n5,int n6,int …

Member Avatar for Dave Sinkula
-1
82
Member Avatar for PDB1982

Your attempt at reading the data from the file needs a lot of work. You're only trying to read the id and the grades, for example, but you pretend as if you've read the names. Also, you need to learn how to index arrays.

Member Avatar for Dave Sinkula
0
90
Member Avatar for daviddoria

Using gcc? [CODE]gcc -E main.cpp[/CODE] [edit]Some code... [CODE]#include <stdio.h> #define SetMacro(name,type) \ virtual void Set##name (type _arg) SetMacro(foo,int) { } int main() { return 0; }[/CODE] gcc's output: [CODE]... virtual void Setfoo (int _arg) { } int main() { return 0; }[/CODE]

Member Avatar for daviddoria
0
138
Member Avatar for titosd
Member Avatar for anonymous alias
0
171
Member Avatar for richman0829

You can't do this in the declaration: [CODE]const double PI = 3.1416;[/CODE] Initialize PI in the constructor... [CODE]class Circle { private: double radius; const double PI; public: Circle(double rad = 0) : radius(rad), PI(3.1416) { } // ...[/CODE]Or make it static... [code]{ private: double radius; [COLOR="Red"]static const double PI;[/COLOR] public: …

Member Avatar for richman0829
0
156
Member Avatar for cwarn23

[QUOTE=~s.o.s~;1073428]IMO the main problem I think is with the way the questions are phrased. People tend to post their entire mind dump when asking questions which presents a difficulty to those trying to answer the questions. I've seen countless questions narrating the entire use case [i need to create a …

Member Avatar for Dave Sinkula
0
164
Member Avatar for Dave Sinkula

In [URL="http://www.daniweb.com/forums/post1071291.html#post1071291"]another post[/URL] I found the following construct: [CODE]#define STATIC_ASSERT(condition) \ do \ char foo[condition] = {0}; \ while ( false );[/CODE] First, I had to do a [URL="http://clusty.com/search?query=static%20assert%20compile%20time"]search[/URL] to see whether "static" meant "compile-time" here (that poor keyword [I]static[/I], it's got too many overloaded meanings in C and C++). …

Member Avatar for jephthah
1
183
Member Avatar for wittykitty

Or change the scope of [ICODE]i[/ICODE]. Remember to return a value. And to initialize sum. [CODE]float getAverageGrade (float grades[], int count) { float sum [COLOR="Red"]= 0[/COLOR]; float average; [COLOR="Green"]int i;[/COLOR] for (i=0; i<count; i++) { sum += grades[i]; } average=sum/i; //I have tried this in the loop and in a …

Member Avatar for jonsca
0
221
Member Avatar for speedy94519

[url]http://web.archive.org/web/20080618001558/c-faq.com/bool/bool2.html[/url]

Member Avatar for Narue
0
295
Member Avatar for FancyShoes

The result of the [ICODE]||[/ICODE] operator will be either 0 or 1. Let's walk through this: [code]if ( 1 == ([COLOR="Red"]2 || 2[/COLOR] || 2) )[/code] [code]if ( 1 == ([COLOR="Red"]1 || 2[/COLOR]) )[/code] [code]if ( [COLOR="Red"]1 == 1[/COLOR] )[/code] [code]if ( 1 )[/code] So your condition is always true. …

Member Avatar for Dave Sinkula
0
100
Member Avatar for hassedo

When there are compiler errors, you get no .exe. You need to fix the errors before the program will be created; once an .exe is build you can run it. You're trying to compare an int to a structure: [code]//structure for dimension typedef struct{ mNum **pX;//declares double pointer for matrix …

Member Avatar for hassedo
0
94
Member Avatar for tgreiner

[QUOTE=tgreiner;1070551]I am having a problem with overloading an operator within a class structure. Below is the program that illustrates my problem. It defines a class Matrix, creates two matrices and multiplies them. I created to multiplication functions. The first is a straight function, the second uses the overloaded * operator. …

Member Avatar for Dave Sinkula
0
2K
Member Avatar for simonfoley

[QUOTE=simonfoley;1071736]Got gets() from my tutor! It was part of a lesson on string handling.[/QUOTE]Oh, my. Don't expect to learn C or C++ in the course you are taking. [url=http://www.daniweb.com/tutorials/tutorial71858.html]User Input: Strings and Numbers [C++][/url] [url=http://www.daniweb.com/tutorials/tutorial45806.html]User Input: Strings and Numbers [C][/url]

Member Avatar for simonfoley
0
234
Member Avatar for new programer

[QUOTE=new programer;1070558]are you suggesting this ? [CODE]string concat(const char* title, const char* first_name, const char* last_name, int l1, int l2, int l3) { string full_name; for(int i=0; i< l1; i++) full_name = title[i]; for(int i=0; i<l2; i++) full_name = [COLOR="Red"]full_name + [/COLOR]first_name[i]; for(int i=0; i<l3; i++) full_name = [COLOR="Red"]full_name + …

Member Avatar for new programer
0
156
Member Avatar for Frederick2

I only skimmed your question, but it sounded like: [url]http://parashift.com/c++-faq-lite/templates.html#faq-35.12[/url] [edit]Short fix? [CODE]//Main.cpp #include <stdio.h> #include <string.h> #include "CClient.h" #include "TArray.[COLOR="Red"]cpp[/COLOR]" [/CODE]

Member Avatar for Frederick2
0
199
Member Avatar for newcoder777

[CODE]#include <stdio.h> int main() { const char filename[] = "file.txt"; FILE *file = fopen(filename, "r"); if ( file ) { char line[BUFSIZ], text[10]; [COLOR="Red"]while ( fgets(line, sizeof line, file) )[/COLOR] { [COLOR="Red"]if ( sscanf(line, "%9[^, .]", text) == 1 )[/COLOR] { printf("text = \"%s\"\n", text); } } } return 0; …

Member Avatar for hichnam
0
120
Member Avatar for Happypants

Are you sure you've got the correct [URL="http://en.wikipedia.org/wiki/Body_mass_index"]formula[/URL]? Checking the return value from scanf is a good idea. [code]#include <stdio.h> int main(void) { float height, weight, bmi; /* * Get user input. */ for ( ;; ) { int ch; printf("Enter your height in inches and weight in pounds: "); …

Member Avatar for Happypants
0
174
Member Avatar for jcax
Member Avatar for bonotevo

[QUOTE=bonotevo;1069425]This is my first post so please bear with me. I am bringing in 2 files into 2 arrays and then trying co compare the arrays to each other. When I compare the arrays, I am trying to find out how many locations have matching letters in both strings. ) …

Member Avatar for Dave Sinkula
0
301

The End.