-
March 4th, 2006, 09:03 AM
#1
need files
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!!!
Last edited by Siddhartha; March 4th, 2006 at 10:06 AM.
-
March 4th, 2006, 09:59 AM
#2
Re: need files
Is this supposed to be a joke or something? You think anyone will send someting to that email address?
-
March 4th, 2006, 10:02 AM
#3
Re: need files
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...
-
March 4th, 2006, 10:06 AM
#4
Re: need files
[ cleaned ]
Regards,
Siddhartha
PS: Mosche, you need to read the Acceptable Use Policy. That was too close.
-
March 4th, 2006, 10:14 AM
#5
Re: need files
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
-
March 4th, 2006, 10:23 AM
#6
Re: need files
Originally Posted by moshe2
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.
-
March 4th, 2006, 10:23 AM
#7
Re: need files
Originally Posted by moshe2
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.
-
March 4th, 2006, 10:29 AM
#8
Re: need files
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?
-
March 4th, 2006, 10:31 AM
#9
Re: need files
Originally Posted by moshe2
employer??? im 15 yearsold
I guessed that.
Hence I said "prospective employer".
Okay, post your code here, and put this [/CODE] tag around it (the first one without the slash).
-
March 4th, 2006, 10:40 AM
#10
Re: need files
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!!!
Code:
/* 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
-
March 4th, 2006, 11:17 AM
#11
Re: need files
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.
Code:
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.
}
"Programs must be written for people to read, and only incidentally for machines to execute."
-
March 4th, 2006, 11:23 AM
#12
Re: need files
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
-
March 4th, 2006, 11:38 AM
#13
Re: need files
Well, if you have a code like this (try to run it - it works fine, just input a number):
Code:
#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.
"Programs must be written for people to read, and only incidentally for machines to execute."
-
March 4th, 2006, 11:53 AM
#14
Re: need files
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
-
March 4th, 2006, 12:00 PM
#15
Re: need files
Originally Posted by moshe2
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
Please don't forget to rate users who helped you!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|