Click to See Complete Forum and Search --> : need files


moshe2
March 4th, 2006, 08:03 AM
hello, if u dont remember me, i was writing a little program that checks if everything is working in target source file..

i checked it several time on my computer but if someone could send me their old source files of any program, as long as it's big... so that my program will have to try hard :)

u could publish them here, or send it to [Sid: Deleted Profane Email Address] (without all the underscores..)

thanks alot!!!

cilu
March 4th, 2006, 08:59 AM
Is this supposed to be a joke or something? You think anyone will send someting to that email address?

moshe2
March 4th, 2006, 09:02 AM
umm... im sorry but that's my email.. i really not trying to do something bad here..
would u prefer that i will publish my code here and u will check it on your computer and tell me how was it?
moshe...

Siddhartha
March 4th, 2006, 09:06 AM
[ cleaned ]

Regards,
Siddhartha

PS: Mosche, you need to read the Acceptable Use Policy (http://www.jupitermedia.com/corporate/privacy/aup.html). That was too close.

moshe2
March 4th, 2006, 09:14 AM
what could i do.. i wanted to publish my email and it is my email.... not to hert anyone i placed underscores so the word wont be published.. sorry

Gabriel Fleseriu
March 4th, 2006, 09:23 AM
what could i do.. i wanted to publish my email and it is my email.... not to hert anyone i placed underscores so the word wont be published.. sorry

You can register a free email address with a zillion providers nowdays. And you can choose an alias that's not offensive.

Siddhartha
March 4th, 2006, 09:23 AM
what could i do..
Do yourself a favour, make a new email address if you want to be taken seriously.

I am very sure - no prospective employer is going to invite you for an interview on that one.

And now, to save your thread - I would recommend that you post the code where you faced problems (use code tags) with an explanation on purpose; else, this thread looks pretty meaningless. ;)

moshe2
March 4th, 2006, 09:29 AM
employer??? im 15 yearsold
anyway, i will open myself a new email.

any way, im relativly new here.. what are code tags?

shouldn't i copy paste my code here?

Siddhartha
March 4th, 2006, 09:31 AM
employer??? im 15 yearsold
I guessed that. :D
Hence I said "prospective employer".

Okay, post your code here, and put this [/CODE] tag around it (the first one without the slash).

moshe2
March 4th, 2006, 09:40 AM
if you could just copy this to your compiler, run it on one or more of your projects or source files and tell me how did it go....
thnks!!!



/* ALL RIGHTS RESERVED MOSHE PROGRAMMING */
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{ //main open
string Fname; int a[16]={0}; char ch=' ',pch=' ',ppch=' ',type='n'; double b=0,c=0,d=0,e=0,f=0;
cout<<"input file's name (c:/file.type):\n\n"; cin>>Fname;
ifstream scan(Fname.c_str());
if(!scan){cout<<"Error in input file! ";}
if(scan)
{ //scan open
while(scan.get(ch))
{ //while-scan open

while(1<2) //demi-loops
{ if(pch=='/' && ch=='/' && type=='n')
{type='c'; a[0]=a[0]-2; a[12]=a[12]+2; a[11]++; a[13]++; break;}
if(type=='c' && ch=='\n') {type='n'; a[9]--; break;} break;}
while(1<2) //demi-loops
{ if(pch=='/' && ch=='*' && type=='n') {type='m'; a[0]--; a[11]++; a[12]++; a[14]++; break;}
if(pch=='*' && ch=='/' && type=='m') {type='n'; a[0]--; a[12]++; break;} break;}
while(1<2) //demi-loops
{ if(pch!='\\' && ch=='\"' && type=='n') {type='t'; break;}
if(pch!='\\' && ch=='\"' && type=='t') {type='n'; break;}
if(pch=='\\' && ch=='\"' && type=='n') {type='n'; a[7]--; break;}
if(pch=='\\' && ch=='\"' && type=='t') {type='t'; a[7]--; break;}
if(pch=='\\' && ch=='\'' && (type=='t' or type=='n')) {a[8]--; break;} break;}

if(type=='n') {
if(ch=='('){a[1]++;} if(ch==')'){a[2]++;}
if(ch=='{'){a[3]++;} if(ch=='}'){a[4]++;}
if(ch=='['){a[5]++;} if(ch==']'){a[6]++;}
if(ch=='\"'){a[7]++;} if(ch=='\''){a[8]++;}
if(ch=='\n'){a[9]++;} if(ch==';'){a[10]++;}
a[0]++; }
if(type=='t') {a[0]++; if(ch=='\"'){a[7]++;}}
if(type=='c') {a[12]++;}
if(type=='m') {if(ch=='\n'){a[11]++;} a[12]++;} if(ch=='\n'){a[15]++;}
if(a[0]>2){ppch=pch;} if(a[0]>1){pch=ch;}
} //while-scan close

scan.close(); system("cls"); cout<<"FILE ANALYSIS ON "<<Fname<<":\n\n";
cout<<"CODE ANALYSIS-\n";
cout<<"number of *(* in use= "<<a[1]<<"\n"; cout<<"number of *)* = "<<a[2]<<"\n";
cout<<"status of *()* -----> "; if(a[1]==a[2]){cout<<"OK.\n";} if(a[1]!=a[2]){cout<<"ERROR!!\n";}
cout<<"number of *{* = "<<a[3]<<"\n"; cout<<"number of *}* = "<<a[4]<<"\n";
cout<<"status of *{}* -----> "; if(a[3]==a[4]){cout<<"OK.\n";} if(a[3]!=a[4]){cout<<"ERROR!!\n";}
cout<<"number of *[* = "<<a[5]<<"\n"; cout<<"number of *]* = "<<a[6]<<"\n";
cout<<"status of *[]* -----> "; if(a[5]==a[6]){cout<<"OK.\n";} if(a[5]!=a[6]){cout<<"ERROR!!\n";}
cout<<"number of * \" * is "<<a[7];
b=(a[7]+0.6)/2; for(c=0.3;c<10000000;c++){if(c==b){c=-8; break;}}
if(c==-8){cout<<" -----> OK!!\n";} if(c!=-8){cout<<" -----> ERROR!!\n";}
cout<<"number of * \' * is "<<a[8];
d=(a[8]+0.6)/2; for(e=0.3;e<10000000;e++){if(d==e){e=-8; break;}}
if(e==-8){cout<<" -----> OK!!\n";} if(e!=-8){cout<<" -----> ERROR!!\n";}
cout<<"number of commands in file= "<<a[10]<<"\n";
cout<<"number of code lines in file= "<<a[9]<<"\n";
cout<<"number of code chars in file= "<<a[0]<<"\n\n";

cout<<"COMMENTS ANALYSIS-\n";
while(1<2) //demi-loops
{if(a[13]==0 && a[14]==0){cout<<"this file doesn't contain comments of any kind.\n\n"; break;}
cout<<"number of single-line comments (//) in file = "<<a[13]<<"\n";
cout<<"number of multiple-line comments (/**/) in file= "<<a[14]<<"\n";
cout<<"number of comments lines in file= "<<a[11]<<"\n";
cout<<"number of comments chars in file= "<<a[12]<<"\n\n"; break;
}

cout<<"GENERAL FILE ANALYSIS-\n";
cout<<"number of total lines in file= "<<a[15]<<"\n";
cout<<"number of total chars in file= "<<a[0]+a[12]<<"\n";
cout<<"average number of chars in file ~ "<<(a[0]+a[12])/(a[15])<<"\n\n";

cout<<"general status of file= "; if(a[0]+a[12]<2){cout<<"EMPTY! "; f=1;}
if(((a[1]==a[2])&&(a[3]==a[4])&&(a[5]==a[6])&&(c==-8)&&(e==-8))&&f==0){cout<<"OK! ";}
if(((a[1]!=a[2])or(a[3]!=a[4])or(a[5]!=a[6])or(c!=-8)or(e!=-8))&&f==0){cout<<"ERROR! ";}
} //scan close
cin>>Fname;
} //main close

RoboTact
March 4th, 2006, 10:17 AM
Don't let it become that complicated.
Don't use magic numbers (or characters). You used variable type to identify current state (read more at 'state automata'). But you can define enum of states instead of characters. Why do you use that array to store collected info? Use named variables instead. And don't be greedy for identifier length. Try to rework your code. It's not the question of correctness really, since it matters little if code is impossible to read. First make it readable, then make it work, debug, and make it even more readable.enum State {
NORMAL_CODE,
LINE_COMMENT,
BLOCK_COMMENT,
CHARACTER_STRING
};

State type = NORMAL_CODE;
int num_line_comments = 0;
...
switch(type) {
case NORMAL_CODE: {
// write code handling normal code here

// for example:
if((pch=='/') && (ch=='/')) {
type = LINE_COMMENT;
num_line_comments++;
}
} break;
case BLOCK_COMMENT: {
} break;
// etc.
}

moshe2
March 4th, 2006, 10:23 AM
im new in programming.. i did not understand why i need to change it if it works, and if it is reading a 40000 lined-file in less then a sec..

anyway what is that enum and all those strage commands? :)

moshe

RoboTact
March 4th, 2006, 10:38 AM
Well, if you have a code like this (try to run it - it works fine, just input a number):#include <stdio.h>

char(a)(1),(l)((a)+(47)),(m)(l),(n)(getc(stdin)-(m));

struct foo
{foo(){l+=a,a=(~a+1^a)&!((~((m+=!(48^l))-!(48^l))+l)&&(l^48))+~0^(~a+1),putc((10^l)&!(l^48)+~0^10,stdout);}};

int main()
{
delete[] new foo[n*n+n];
return 0;
}how are you going to modify it? To add functionality, to fix the bug, etc.? It's just impossible. You'll have to rewrite it from scratch. It's the same with code you posted. Not that exaggerated of course, but the idea is the same.

What exactly you don't understand about code I posted in first message? It uses switch and enum - quite simple concepts, you can read about them anywhere.

moshe2
March 4th, 2006, 10:53 AM
could you explain in a few words what are those functions?

i didnt really understand what did you program in the last massage was supposed to do... and where is the bug.. but nevermind, i got the concept i think....

instead of a[16], b,c,d,e........ i should write chartype[16] for exmp? to keep it organized?
and the enum ans switch are for the same purpose? just to keep it easy to view? would it be better if it would just be shorter??

thanks alot for your replay!!
moshe

philkr
March 4th, 2006, 11:00 AM
anyway, i will open myself a new email.
If you want to keep your address, but use other names to announce in public:
www.spamgourmet.com

RoboTact
March 4th, 2006, 11:02 AM
i didnt really understand what did you program in the last massage was supposed to do... and where is the bug.. but nevermind, i got the concept i think....You can run it on your compiler and see. IFAIK, there is no bug.

instead of a[16], b,c,d,e........ i should write chartype[16] for exmp? to keep it organized?About that. And you shouldn't use chartype[16] as single array too, since it contains different things and you don't need to remember things like 'index 11 is reposible for this, and index 14 for that'. If you still use it this way, don't use numberic indices, instead define symbolic constants:const int LCOMMENT_ID = 11;
...
chartype[LCOMMENT_ID]++;and the enum ans switch are for the same purpose? just to keep it easy to view?Yes, just for that purpose. Switch makes it a bit faster though. would it be better if it would just be shorter??No value in that. Bottleneck in programming is not typing, but thinking. If you type a bit more and save some time later on thinking about what that code means, you save total time and make it more meaningful.

moshe2
March 4th, 2006, 11:30 AM
i understand what your are saying but i think it is only segnificantly-important in real market-programms and not in little non-professional proggrams done by 15 year-olds.......
no?
anyway can u say in a few words what enum and switch do and how do i use them?

--moshe

RoboTact
March 4th, 2006, 11:44 AM
i understand what your are saying but i think it is only segnificantly-important in real market-programms and not in little non-professional proggrams done by 15 year-olds.......
no?No. It's only a difference of degree. If you write some 1000 line programm, it's much simplier if you write it organized. If you write 10000 lines programm, it may become nightmare without proper principles. Anyway, there are about no reasons NOT TO write clean. And 15 years is not too much of a limit if you are determined.

moshe2
March 4th, 2006, 12:00 PM
maybe you could give me a list of these basic functions for me to search the web? im working now with a very short list of known functions and commands.. maybe u can direct me to such list elsewere?

anyway, can u please at-least describe the meannings of switch & enum?

moshe

RoboTact
March 4th, 2006, 12:27 PM
maybe you could give me a list of these basic functions for me to search the web? im working now with a very short list of known functions and commands.. maybe u can direct me to such list elsewere?You should read some book to get integral picture.
http://cm.bell-labs.com/cm/cs/cbook/

anyway, can u please at-least describe the meannings of switch & enum?enum is used to assign symbolic constants different values without specifying these values yourself. If you writeenum Fruits {
APPLE = 0,
PEAR
}; you obtain constant APPLE having a value of 0 and constant PEAR with value of 1. You now may identify element of enumeration by specifying the constant. If you have some fruit object, you can crate a variable of type enum Fruit and assign it one of possible valuesenum Fruit fruit_type;
fruit_type = PEAR; Now you can test for type of fruit:if(fruit_type==APPLE) {... do somethig}

Switch is mutli-way branch. You specify the variable and expected values of it. If values match, you have a jumt to corresponding case label. For example:switch(fruit_type) {
case APPLE:
// this label'll be jumped to if (fruit_type==APPLE)
case PEAR:
// note that case is just a label, so this point'll be reached even it
// fruit_type is APPLE, unleas you use break to exit switch block.
break;
}

moshe2
March 4th, 2006, 12:52 PM
while(1<2) //demi-loops
{ if(pch=='/' && ch=='/' && type=='n') {type='c'; a[0]=a[0]-2; a[12]=a[12]+2; a[11]++; a[13]++; break;}
if(type=='c' && ch=='\n') {type='n'; a[9]--; break;} break;}
while(1<2) //demi-loops
{ if(pch=='/' && ch=='*' && type=='n') {type='m'; a[0]--; a[11]++; a[12]++; a[14]++; break;}
if(pch=='*' && ch=='/' && type=='m') {type='n'; a[0]--; a[12]++; break;} break;}
while(1<2) //demi-loops
{ if(pch!='\\' && ch=='\"' && type=='n') {type='t'; break;}
if(pch!='\\' && ch=='\"' && type=='t') {type='n'; break;}
if(pch=='\\' && ch=='\"' && type=='n') {type='n'; a[7]--; break;}
if(pch=='\\' && ch=='\"' && type=='t') {type='t'; a[7]--; break;}
if(pch=='\\' && ch=='\'' && (type=='t' or type=='n')) {a[8]--; break;} break;}



your intension was that the switch command should come instead of the demi-loops??

if so, should the switch or the enum be outside of the main()? all my programs so far were very simple-structured (without none classes and such things), and ALL commands were inside the main func..

RoboTact
March 4th, 2006, 01:20 PM
your intension was that the switch command should come instead of the demi-loops??There actually is no reason for those loops - I think you lack else keyword...

moshe2
March 4th, 2006, 01:27 PM
no... not at all..... look up.. each 2 functions inside a demi-loop has few states-

1. function number 1 will run, function number 2 will NOT run.
2. function number 2 will run, function number 1 will NOT run.
3. NONE will run and the program will continue (because there is 3 breaks
for each loop with 2 functions- one break for each function ending and
one break for the whole deal (if none are executed).

any way... if one of them work (and it doesn't have to be like this)- the other will surely NOT work!

do you understand what i tryed to do? i know its a bit rough but im a beginner...

RoboTact
March 4th, 2006, 01:48 PM
I mean that while(1<2) //demi-loops
{ if(pch=='/' && ch=='/' && type=='n') {type='c'; a[0]=a[0]-2; a[12]=a[12]+2; a[11]++; a[13]++; break;}
if(type=='c' && ch=='\n') {type='n'; a[9]--; break;} break;} is equivalent toif(type=='n' && pch=='/' && ch=='/') {
type='c';
a[0]-=2;
a[12]+=2;
a[11]++;
a[13]++;
} else if(type=='c' && ch=='\n') {
type='n';
a[9]--;
}which is not that esoteric.

moshe2
March 4th, 2006, 01:57 PM
i knew that there is "if" and there is "else".. i didnt knew that there is "else if"..

if(a==b){...}
else if(b==c){...}

Q: the else-if command will run only if--> ((a!=b) && (b==c)) ?

RoboTact
March 4th, 2006, 04:32 PM
i knew that there is "if" and there is "else".. i didnt knew that there is "else if"..

if(a==b){...}
else if(b==c){...}There is no "else if". Last if is just under else, like if you have a codeif(A) B;
else C;where C is actually "if (D) E", so that code looks likeif(A) B;
else if(D) E;So, that second 'if' is checked only if first 'if' failed.

moshe2
March 4th, 2006, 11:12 PM
There is no "else if". Last if is just under else, like if you have a codeif(A) B;
else C;where C is actually "if (D) E", so that code looks likeif(A) B;
else if(D) E;So, that second 'if' is checked only if first 'if' failed.

ok, but there is only 1 else if possible after each if?

if (a) {b;}
else if (c) {d;}
else if (e) {f;}

what does this means? if it exists?


another 2 beginner's questions.....:

1.
enum CharState
{ A_BRACKET_OPEN = 0,
A_BRACKET_CLOSE = 0,
B_BRACKET_OPEN = 0,
B_BRACKET_CLOSE = 0 };

but later on, i cant manipulate them... i can't do B_BRACKET_OPEN++; for instance..

2.how do i create some function that will do all this string Input_File_Name;

cout<<"input file's name (c:/file.type):\n\n";
cin>>Input_File_Name;
ifstream ScanFile(Input_File_Name.c_str());

outside of main(), and will be called in main for scanning the file with the symbolic key-work "scan"...??

thanks alot!!!
moshe.

RoboTact
March 5th, 2006, 01:28 AM
ok, but there is only 1 else if possible after each if?

if (a) {b;}
else if (c) {d;}
else if (e) {f;}

what does this means? if it exists?
It means
if (a) {b;}
else {
if (c) {d;}
else {
if (e) {f;}
}
}

1.
enum CharState
{ A_BRACKET_OPEN = 0,
A_BRACKET_CLOSE = 0,
B_BRACKET_OPEN = 0,
B_BRACKET_CLOSE = 0 };

but later on, i cant manipulate them... i can't do B_BRACKET_OPEN++; for instance..It's symbolic constant. There is no sense in modifying it. And it's disabled too.
2.how do i create some function that will do all this string Input_File_Name;Not sure what you mean.

moshe2
March 5th, 2006, 12:59 PM
gain, how can i make the a[16] better?

( a[16] have the information on how many (){}[]; and more..... )

-moshe

RoboTact
March 5th, 2006, 01:26 PM
gain, how can i make the a[16] better?

( a[16] have the information on how many (){}[]; and more..... )

-mosheAs you use it now, you don't need array at all. You may use different variables instead of elements of array at each index, with names of their own.
Anyway, even if you don't change the way it is now, you should actually name those indices you use. Don't write a[12], write instead a[NUM_COMMENTS], where NUM_COMMENTS equals to 12 and defined beforehand.