Detect "\" in directory
Suppose You try to get the app.path when the app is in the C Drive. the result is "C:\". if the app is in another directory the result may be "C:\Directory". notice there is no backslash. most people skip this because they don't think it is a problem, but it is. when you put in a program, app.path & "\filename.file", when it is in the C Drive or if you put app.path & "filename.file" in a named directory, the computer will either return "C:\\filename.file" or "C:\Directoryfilename.file". this code will show you how to detect the backslash and deal with it.
AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
'this code will give you a valid filename, whether the app.path return has a backslash or not, and displays a message box.
'Please Vote for me at Planet Source Code
if right(app.path,1) = "\" then 'sees if the directory has a backslash at the end of it
msgbox app.path & "filename.file"
goto ResumeMe
end if
msgbox app.path & "\filename.file"
ResumeMe:
#include<iostream.h>
#include<conio.h>
void main(){
int i,cm,cy,d=2; //cm = current month, cy = current year. d=2 because 1st jan,1980 is tuesday.
int m[12]={31,28,31,30,31,30,31,31,30,31,30,31}; //Array to hold no. of days in all months.
clrscr();
cout<<"Enter month and year:";
cin>>cm>>cy;
if(cm<1||cm>12||cy<1980){
cout<<"ERROR! Cannot display below 1980.";
return; //returns from main
}
m[1]=!(cy%4)+28; // !(cy%4) is true if cy is a leapyear
for(i=1980;i<cy;i++){
d+=!(i%4)+365;
d%=7; //calculates the effective day.
}
for(i=2;i<=cm;i++)
d+=m[i-2];
d%=7;
cout<<"\nSu\tMo\tTu\tWe\tTh\tFr\tSa\n";
for(i=0;i<d;i++)cout<<" \t";
for(i=1;i<=m[cm-1];i++,d++){
cout<<i<<'\t';
if(!((d+1)%7))cout<<endl;
}
getch();
}