129 Posted Topics

Member Avatar for saransh60

hi from what i can see ill explain whats going on [code] #include<iostream> #include<string.h> int main() { char* str="my name"; //char* means pointer so this creates a pointer to a character array called str. //str is initilised upon creation to the string "my name". As far as i know this …

Member Avatar for Fbody
0
136
Member Avatar for Kanoisa

Hi guys, Im working through accelerated c++ book and in chapter 4 ex 2 i had to build a program that displayed the square of ints (i) 1->100 inclusive using setw() to align the results. this i did ok and it works fine like 3 lines of code. However in …

Member Avatar for arkoenig
1
183
Member Avatar for khaled mohamed

Hi, I get the feeling your wanting some keyboard interaction here? Depending on the graphics API your using you have to use some functions in them to enable and use text. Its quite a bit more involved than normal console as an example please look at this link which is …

Member Avatar for Kanoisa
0
96
Member Avatar for maplax

Hi, To store the books thats a valid approach but manually coding all the book names is a bad idea i think. i suggest scanning a directory and geting the file names if they are in one directory see link -> [URL="http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1046380353&id=1044780608"]LINK[/URL] for a few possible ways to do this. …

Member Avatar for mrnutty
0
110
Member Avatar for crapgarden

[quote] 5.6 - Multiple Return statements in a function. I heard that you can have multiple return statements within a single function. Could someone show me an example of this, and explain to me how the program knows not to exit the function after the first one? ...also why would …

Member Avatar for Ancient Dragon
0
237
Member Avatar for Kanoisa

Hi all, Im working on the design of a function at the moment and im not sure if the if statement i want to do is safe. Ill start with the data structures i have as this is where the problem could come from. (simplified with relevent bits only) [code] …

Member Avatar for Kanoisa
0
118
Member Avatar for akilank

If you are talking about programming a router or similar to which you can write to the processors program instructions memory, it all depends on the processor in use. such as most 8051's (its definately not one of those) only support regular C (some enhanced 8051's have native java support), …

Member Avatar for Kanoisa
0
240
Member Avatar for technology

heya there are two options here for you, you can declare a character and read with cin or tell cin that you want only a character such as below [code] char myChar; cin>>myChar;//cin sees a char variable so reads only a char //or myChar = cin.get(); //the same as getchar …

Member Avatar for ShadowScripter
0
197
Member Avatar for Kanoisa

Hiya, Im trying make a simple cards game and i was wondering how in c++ can i use the characters ♠ ♣ ♥ ♦ , i think it would be betetr than me printing out the words each time, Are these in some extended character set anywhere? i tried googling …

Member Avatar for Kanoisa
0
1K
Member Avatar for Jackie91

Jackie, If you wish a simple method for checking if the user has entered any numbers instead of just characters you can use the isalpha() function. it accepts a single character as input so you could make a check function something like,.. [code] bool checkForNoNumbers(string &str) { char* temp;// temp …

Member Avatar for ShadowScripter
0
94
Member Avatar for Anyzen

Ok what Danny is saying that you currently have 2 mains in the same project i agree, I would like to suggest that even for trivial examples try using more meaningful names as this will be handy later on. What he suggests is that you currently have 2 sets of …

Member Avatar for Anyzen
0
193
Member Avatar for Kanoisa

Hi guys, As some of you may know im working on learning more c++ and trying to become a good programmer, iv got things like classes, function pointers and template classes under the belt as far as i can see (although to be honest i have never found a place …

Member Avatar for Ketsuekiame
0
198
Member Avatar for sisterjo

Ok iv only had a short look at this but looking at the while loop [code] while (infile) { // processing statements grossPay = hours * rate; taxPayable = grossEarnings * 0.15; medicalLevy = grossEarings * 0.01; netEarnings = grossEarnings - taxPayable - medicalLevy; totalGrossEarnings = totalGrossEarnings + grossEarnings; totalTax …

Member Avatar for Kanoisa
0
188
Member Avatar for rayborn66

Also just like to point out another flaw [code] fin.open("getfromthisfile.txt"); if(fin.fail()) { cout << "Input file opening failed.\n"; exit(1); } fout.open("sendtothisfile.txt"); if(fin.fail()) { cout << "Input file opening failed.\n"; exit(1); } [/code] WHY are you checking if the istream failed again after opening an ostream, bad use of copy and …

Member Avatar for Kanoisa
0
232
Member Avatar for fenerista

[QUOTE]Is there any way to get a value on a matrix in a list exactly like "matx[3][4]" with square brackets like default C matrix [/QUOTE] The [ ] operator can be overloaded but ill admit im not very strong on operator overloading so i dont know how to do it …

Member Avatar for fenerista
0
130
Member Avatar for p@rse

Ok for this i would recomend making a key making function something like the following [code] void makeKey(char *keyBuff, int keyLen) { unsigned char randomKeyByte;//var to hold random key if(strlen(keyBuff)<keyLen)//if key buffer is to small we have a problem { cout<<"Key buffer is to small"<<endl; cout<<"Requested key of size "<<keyLen; …

Member Avatar for p@rse
0
112
Member Avatar for completehoax

Hey For this problem i have devised a simple solution that i think meets your needs please consider the following. [CODE]#include <iostream> #include <cctype>> using namespace std; int main() { char ch; char compare; cout << "Enter any character, lowercase or uppercase: "; ch = cin.get(); if(isalpha(ch))//check the character is …

Member Avatar for Kanoisa
0
104
Member Avatar for Kanoisa

Hi everyone, I'm not so sure if this belongs in here or in computer science but I think as I want to use c++ this may be the place. I was wondering if anyone could point me towards some tutorials/references or books on methods for approaching the design of larger …

Member Avatar for Bench
0
144
Member Avatar for KAY111

Just looking at this very complex for loop that whole thing looks to be a for loop condition so where is the code that is executed upon each iteration? Try breaking it down and see if thats what you expected/wanted

Member Avatar for KAY111
0
1K
Member Avatar for YasaminKh

[QUOTE]error: 'itoa' was not declared in this scope[/QUOTE] to use itoa ensure you include cstdlib (see below) [code] #include <cstdlib> [/code] this should solve the problem allowing you to += the chars into the string

Member Avatar for YasaminKh
0
190
Member Avatar for merse

the character '' ? it would be [code] cout<<'\'<<endl; //just the single character cout<<"c:\\someFile"<<endl; //used as part of a string //second prints to console "c:\someFile" [/code] edit: ..... beaten to the punch again :'( lols

Member Avatar for mod666
0
106
Member Avatar for bklearner

Ok i dont know if this s really the best way to help here but i have a couple of classes i made a while ago. one C_Day is a class which holds a list of tasks to be done on that day which are stored as a linked list. …

Member Avatar for Taywin
0
148
Member Avatar for Galdzor

Yeah basically thats what they are saying and i have found additional formating things and some bugs in functionality. my code below

Member Avatar for Kanoisa
0
181
Member Avatar for eggmatters

Hi i tried ur code, i couldent get it to even see the pos struct with 2 cpp files (as i expected) so i made the above code as a .h file and then added a #include to it in the main and then it allowed me to use the …

Member Avatar for eggmatters
0
148
Member Avatar for Kanoisa

Hiya Im trying to make a few efficient maths classes that will optomise using SIMD SSE or SSE2 if the target CPU supports those SIMD variants or failing to support either use a normal CPU bound c++ version. The issue im having is that i want to have for example …

Member Avatar for StuXYZ
0
96
Member Avatar for YasaminKh

Have you tried something like [code] FILE *h_file; int numberStartPos; int numberEndPos; char temp; string result; /*loop from start pos to end pos reading bytes (im assuming ascii chars) and appending them to the string result*/ for(int x = numberStartPos; x<numberEndPos; x++) { fseek(h_file, x ,SEEK_SET); //seek to the next …

Member Avatar for Kanoisa
0
116
Member Avatar for Kanoisa

Heya Thanks for taking the time to look at this, i would like some people to review my curent project which is written in c++ using visual studio 2008. Although in VS08 it does not use anything that makes it dependant on it (i dont think) i just wanted to …

Member Avatar for Kanoisa
0
170
Member Avatar for Kanoisa

hey, Just starting to learn how to use classes in c++ and when i try to split my class out of the main code and put it in a headder or a headder and a second source file dev C++ is giving me loads of errors and i dont know …

Member Avatar for Lerner
0
142
Member Avatar for nayrb

Heya, new to c++, just finished a bit of c programming and ur reply really helped thanks nobody told me about the std:: bit not even the book i was using ...but it works now cheers,.... by any chance could you advise when i ened the std:: bit in my …

Member Avatar for AceofSpades19
0
138

The End.