1,494 Posted Topics
Re: Instead of looping throught the arrays, I would try a function like memcmp(). | |
Re: Try something like this. void displayTruck() { for (size_t i = 0; i < counter; ++i) std::cout << itemPtr[i]->getMaker() << itemPtr[i]->getCost() << std::endl; } | |
Re: Since replaceAll() returns void and doesn't change any global variables or state. What does this function accomplish? | |
| |
Re: This forum is not a free tutoring service or a homework completion site. Post your question clearly, post your code clearly indicating where the problem is and post any other pertinent information or data. | |
Re: I think you'll find the answer here. Check the example. http://www.cplusplus.com/reference/istream/basic_istream/seekg/ | |
Re: Could you post an example of the text file chocolates.txt? | |
Re: Here's a big hint which counts the characters. #include <iostream> unsigned long vowels(char ca[], unsigned long v_num) { if ( ca[0] == '\0' ) return v_num; vowels(++ca, ++v_num); } int main(int argc, char** argv) { char str[] = "This is a string to check for vowels"; std::cout << "'" << … | |
Re: Why? Because C++ demands that functions are defined before they are used but you can define your functions like so. double fIntoCm(double); int main() { ... } double fIntoCm(double dIn) { double dCm; dCm = dIn*2.54; return (dCm); } | |
Re: You two errors on line one for (index = 1; index < SIZE; ++); for (index = 1; index < SIZE; ++index) {...} | |
Re: I would go with an array of structures struct personal { std::string name; std::string phone; std::string DOB; }; personal per[10]; | |
Re: Here's a hollow square. I think? #include <iostream> int main(int argc, char** argv) { unsigned int count = 12; for (size_t i = 0; i < count; ++i) { if ( i == 0 ) { std::cout << std::string (count, 'x') << std::endl; continue; } if ( i == count … | |
Re: Did you try reading this link? http://msdn.microsoft.com/en-us/library/ys435b3s%28v=vs.110%29.aspx | |
Re: The basic way is to save the input into a string and then check each character for validity. | |
Re: Your first example should work if the for loop terminates when i = 5. char str1[5] = "code"; char str2[5] = "code"; for(i; i < 5; i++) { printf("The array length is %c %c :\n", str1[i], str2[i]); } | |
Re: int chdir(const char *path); You can use chdir() which is in the unistd.h header file. | |
Re: Should this have a reference to int? void ShowMenu(string& word, int choice); Something like. void ShowMenu(string& word, int & choice) | |
Re: No. You have to take the source code over to a Windows compiler and recompile it into a Windows exe. ![]() | |
Re: You could try something like this: void check_string(const std::string str) { std::cout << "Got->" << str << std::endl; } void print_actors_movies(treePtr root, const std::string name) { if(root == NULL) return; if (root->left) print_actors_movies(root->left, name); std::for_each(root->actors.begin(), root->actors.end(), check_string); if (root->right) print_actors_movies(root->right, name); } I'll leave it to you to check if … | |
Re: #include <iostream> int main() { //prompt for integers //read/extract integers into variables //do calculations } | |
Re: You have this gcc -std=c++11 -std=c++0x -W -Wall tt1.cpp but should it be g++ -std=c++11 -std=c++0x -W -Wall tt1.cpp | |
Re: Maybe I missed it. Where is the question? Are you asking us to write this program for you? | |
Re: Are you looking for a default constructor which will initialize the std::vector member with the values 1, 4, 5 via the constructor initialization list without embracing the C++11 features? | |
Re: Not sure what your problem is. Are you trying to accomplish something like this? server.c #include <stdio.h> #include <stdlib.h> #include <arpa/inet.h> #include <strings.h> #include <string.h> #include <unistd.h> #include <errno.h> #include <signal.h> #define DEFAULT_PROTOCOL 0 #define PORT 50000 #define MSG "\nGot the message!\n" int main(int argc, char**argv) { int listenfd, connfd, … | |
Re: Could it be this Class Please note the uppercase C Or could it be the missing semi-colon here class Base { Base(); ~Base(); void doSomrthing(); } Or here Class MyCLass : public Base{ std::string name; MyCLass(); ~MyCLass(); void init(); } | |
Re: strlen takes a character pointer as its parameter. size_t strlen(const char *s) | |
Re: Could we see an example of the code you tried? | |
Re: Open your file(a.txt) and a temp file. Read the a.txt file writing the results to the temp file. If one of the characters to be written is B then write b first. Finally, delete a.txt and rename temp to a.txt. | |
Re: Try something like this #include <iostream> #include <fstream> int main() { std::ofstream fout("outdata"); for (size_t i = 0; i < 100; ++i) fout << "0x" << std::hex << i << std::endl; return 0; } | |
Re: Are you having problems with the ternary operator? http://msdn.microsoft.com/en-us/library/e4213hs1%28v=vs.71%29.aspx | |
Re: Are you looing for something like this? #!/usr/bin/perl use warnings; use strict; use autodie qw/open close/; print "Enter input filename->"; chomp(my $ifilename = <STDIN>); open(my $IFILE, "<", $ifilename); while ( <$IFILE> ) { chomp; my @data = split(/\t+/, $_); print "@data\n" unless ( $data[3] eq $data[4] )#print this to another … | |
Re: A better question would be - Hi guys, I would like to know How to blink console text using Windows or Mac or Linux. | |
Re: I would investigate pipes or popen. [Click Here](http://perldoc.perl.org/perlopentut.html) | |
Re: Right click on the file in question and select properties. The properties window should have a field 'Full File Path'. If your looking to list the files for the entire project then try the main menu option Edit->Find and choose the proper file name patterns. | |
Re: Try this my @files = sort { $a cmp $b } readdir(DIR); I tried this and it worked. #!/usr/bin/perl use strict; use warnings; my $dir = 'directory_path'; opendir(DIR, $dir) or die $!; foreach( sort { $a cmp $b } readdir(DIR)) { next if (/^\./); print $_,"\n"; } closedir(DIR); exit 0; | |
| |
Re: It might help if you include the version of Netbeans, C/C++ plugin and your compiler. | |
![]() | Re: [QUOTE=neocortex;1180862] Hence, what would be your recommendations and why? Keep in mind that I need Linux for work, thus, seeking for stability and speed over fun and gloom. [/QUOTE] What does that mean 'I need Linux for work'? Do we interpret this as - my Linux must be Debian based … |
Re: [QUOTE=kemaletikan;1032697]Hi fellas, I have a question about disassembled code. I have a very simple assembly code that prints "Hello world" to screen. When I disassembled it by using nasm(ndisasm), I got a text file. After that I opened it and started to analyze it. However, in a section that comes … | |
| |
Re: You need to modify this line to scanf("%d", &arr[i]); Note the &. | |
Re: [QUOTE=Redhaze46;1322805]how hard?[/QUOTE] Try making a parser first and then you'll start to see the 'how hard'. | |
Re: [QUOTE=mandysaini;1071093]Hi Friends, I have heard that it isn't that simple to write a program in linux using c. Lots of commands n stuff.Please simplify what actually I've got to do to run turbo c++ in my linux laptop as I am a beginner.[/QUOTE] Its just as easy as any other … | |
Re: player->draw(s); //errors are these 3 lines, s is an undeclared identifier So where is s defined? | |
Does anyone know how to do this? I attached a program that collects all the command line arguments into a map container noting how many times each command line argument occurs. Now I want to sort this map of information by loading a vector with iterators that point to each … | |
Re: Could you narrow down your problem to something smaller than the entire program? P.S. Please use an appropriate title for your posting. Need Help ASAP isn't very descriptive. | |
Re: Again 'Need Help ASAP' is not a good title. |
The End.