#include"stdio.h"
#include"conio.h"
#include"string.h"
void main(){
char str[20],key[][32]= {"auto","double","int","struct",
"break","else","long","switch","case","enum","register",
"typedef","char","extern","return","union","const","float",
"short","unsigned","continue","for","signed","void","default",
"goto","sizeof","volatile","do","if","static","while" } ;
int i,j=0,flag;
clrscr();
while(j<=6){
flag=0;
printf("\nEnter string : ");
gets(str);
for(i=0;i<=31;i++){
if(flag==strcmpi(str,key[i]))
flag = 1;
}
if(flag==0){
for(i=0;i<strlen(str);i++){
if(str[i]=='_' || isalpha(str[i]) || isdigit(str[i]) && !isspace(str[i]) && !isdigit(str[0]))
flag = 0;
else{
flag = 1;
break;
}
}
}
if(flag==0)
printf("Valid Identifier\n");
else
printf("Invalid Identifier\n");
j++;
}
getch();
}---------------------------------------------------------------------------------------------------
In this Program one array is defined to store keyword to check input is keyword or not using 'strcmpi()' function. In other loop it checks for '_'(checks all 'str[i]') , alphabets(using 'isalpha()') and whitespace (using 'issapce()') constrains and if alphabet(not) or space(detected) then it means input might be containt ant numeric value or special symbol which will go to else part and break out of loop for preventing resetting flag variable.
Computer Solution : Today And Tommorow
Solution About Computer World And It's Problems.
Wednesday, July 13, 2016
Friday, May 20, 2016
Terminal is Not Opening In Linux
When try to open terminal in linux (debian, ubuntu,..) that defaults uses GNOME-Terminal it refuses to start.
And when try to open from cli "root@sys:~# gnome-terminal" from any terminal (install 'Xfce Terminal' or 'LXTerminal' to run following commands)it shows the following error.
This error show that there is some problem to start GNOME Terminal service.
To check the failed services in system by user run the sollowing command systemctl which used for control systemd and processes.
Here its shows the gnome-terminal-server.service unit or service is loaded but not active.
There can be several reason to cause these error like misconfig of terminal profile, system locale is not set.
To solve this first you need to install gnome-terminal by typing :
root@sys:~# apt-get install gnome-terminal
If u have already installed it then 'purge' it so if there is any misconfig of profile or configuration file then it will remove it.
This Package will also remove when you purge the GNOME terminal so install it again.
Reboot the computer and try to open terminal if still getting error then check system locale.
LANG="your locale,shoud not be empty"
To generate locale run following command.
To set your locale run following command(in my case : en_US.UTF-8).
After setting system locale reboot the computer and open gnome-terminal it will open successfully.
And when try to open from cli "root@sys:~# gnome-terminal" from any terminal (install 'Xfce Terminal' or 'LXTerminal' to run following commands)it shows the following error.
Error constructing proxy for org.gnome.Terminal:/org/gnome/Terminal/Factory0: Error calling StartServiceByName for org.gnome.Terminal: Timeout was reached
This error show that there is some problem to start GNOME Terminal service.
To check the failed services in system by user run the sollowing command systemctl which used for control systemd and processes.
root@sys:~# systemctl --user --failed
UNIT LOAD ACTIVE SUB DESCRIPTION
* gnome-terminal-server.service loaded failed failed GNOME Terminal
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
1 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
Here its shows the gnome-terminal-server.service unit or service is loaded but not active.
There can be several reason to cause these error like misconfig of terminal profile, system locale is not set.
To solve this first you need to install gnome-terminal by typing :
root@sys:~# apt-get install gnome-terminal
If u have already installed it then 'purge' it so if there is any misconfig of profile or configuration file then it will remove it.
This Package will also remove when you purge the GNOME terminal so install it again.
root@sys:~# apt-get install gnome-terminal
root@sys:~# apt-get install gnome-core*
root@sys:~# apt-get install gnome-terminal*
Reboot the computer and try to open terminal if still getting error then check system locale.
root@sys:~# localectl
LANG="your locale,shoud not be empty"
To generate locale run following command.
root@sys:~# locale-gen
To set your locale run following command(in my case : en_US.UTF-8).
root@sys:~# localectl set-locale LANG="en_US.UTF-8"
After setting system locale reboot the computer and open gnome-terminal it will open successfully.
Friday, April 1, 2016
Root Access Problem For VLC in Linux
Sometimes its shows the privileges error when trying to open VLC in linux or from terminal even running as root.
error: Cannot determine unprivileged user for VLC!
To solve this error we need to change vlc binary file located at(/usr/bin/vlc by default). Or if u have Hex Editor then open vlc binary file and search for word 'geteuid' and replace it with 'getppid'.
If don't have hex editor then just simply execute this command.
'sed -i 's/geteuid/getppid/g' /usr/bin/vlc'
It which will fix this error .That's it..
error: Cannot determine unprivileged user for VLC!
To solve this error we need to change vlc binary file located at(/usr/bin/vlc by default). Or if u have Hex Editor then open vlc binary file and search for word 'geteuid' and replace it with 'getppid'.
If don't have hex editor then just simply execute this command.
'sed -i 's/geteuid/getppid/g' /usr/bin/vlc'
It which will fix this error .That's it..
Tuesday, March 29, 2016
How to Mount Hibernated Windows Partitions in Linux
ERROR:
Error mounting: mount exited with exit code 14: Windows is hibernated, refused to mount.
Failed to mount '/dev/sda5': Operation not permitted
The NTFS partition is hibernated. Please resume and shutdown Windows
properly, or mount the volume read-only with the 'ro' mount option, or
mount the volume read-write with the 'remove_hiberfile' mount option......
Why ?
You are seeing this error because you hibernated Windows instead of turning it off the normal way (in newer versions of Windows, hibernate might be the default option).
Hibernating saves the current state information to the hard disk and then powers down the computer. When you turn off Windows by hibernating it, you are essentially pausing the system and saving all of that information into a big file called hiberfil.sys This way when you resume from hibernation all of your applications and files will be exactly how you left them. It also sets a flag in hiberfil.sys to let other Operating Systems know that Windows is hibernated.
Shutting down the computer closes all programs and ends all running processes before powering down the computer
Making changes to your Windows partition while it is hibernated could be dangerous, ,t could cause Windows to not resume from hibernation or to crash after resuming.
In Linux to mount hibernated windows do as following:
Make Folder of any name in Media Directory(/media)
e.g. Make folder manually or
sudo mkdir /media/WINTMP
After then Run this command (with superuser permission if needed) in terminal with created folder name where to mount windows partition. Here sda2 is a partition of windows file System so First Check that where your windows partition is stored.
e.g.
sudo mount -t ntfs-3g -o remove_hiberfile /dev/sda2 /media/WINTMP
-------------------------------------------------------------------------------------------------------
Solution for Windows 8 and 10:
There is a new feature in Windows 8 called Fast Startup.This feature is enabled by default, Windows 8 does not actually completely shutdown when you choose shutdown. Instead, it does a "hybrid shutdown". This is something like hibernating; it makes booting Windows 8 back up faster. So, you need to disable this feature to be able to shut it down properly, and be able to mount the Windows partitions. Fast Startup can be Disable from power option in Control Panel.By disabling Fast Startup windows 8 will take a longer time to boot.
If you still aren't able to mount without getting errors, you should turn off hibernation completely. Open Command Prompt as Administrator and Run following Command :
powercfg /h off
Error mounting: mount exited with exit code 14: Windows is hibernated, refused to mount.
Failed to mount '/dev/sda5': Operation not permitted
The NTFS partition is hibernated. Please resume and shutdown Windows
properly, or mount the volume read-only with the 'ro' mount option, or
mount the volume read-write with the 'remove_hiberfile' mount option......
Why ?
You are seeing this error because you hibernated Windows instead of turning it off the normal way (in newer versions of Windows, hibernate might be the default option).
Hibernating saves the current state information to the hard disk and then powers down the computer. When you turn off Windows by hibernating it, you are essentially pausing the system and saving all of that information into a big file called hiberfil.sys This way when you resume from hibernation all of your applications and files will be exactly how you left them. It also sets a flag in hiberfil.sys to let other Operating Systems know that Windows is hibernated.
Shutting down the computer closes all programs and ends all running processes before powering down the computer
Making changes to your Windows partition while it is hibernated could be dangerous, ,t could cause Windows to not resume from hibernation or to crash after resuming.
In Linux to mount hibernated windows do as following:
Make Folder of any name in Media Directory(/media)
e.g. Make folder manually or
sudo mkdir /media/WINTMP
After then Run this command (with superuser permission if needed) in terminal with created folder name where to mount windows partition. Here sda2 is a partition of windows file System so First Check that where your windows partition is stored.
e.g.
sudo mount -t ntfs-3g -o remove_hiberfile /dev/sda2 /media/WINTMP
-------------------------------------------------------------------------------------------------------
Solution for Windows 8 and 10:
There is a new feature in Windows 8 called Fast Startup.This feature is enabled by default, Windows 8 does not actually completely shutdown when you choose shutdown. Instead, it does a "hybrid shutdown". This is something like hibernating; it makes booting Windows 8 back up faster. So, you need to disable this feature to be able to shut it down properly, and be able to mount the Windows partitions. Fast Startup can be Disable from power option in Control Panel.By disabling Fast Startup windows 8 will take a longer time to boot.
If you still aren't able to mount without getting errors, you should turn off hibernation completely. Open Command Prompt as Administrator and Run following Command :
powercfg /h off
Browsing Privacy in Mozilla Firefox using about:config
The about:config (Configuration Editor) Page lists Firefox settings known as preferences that are read from the prefs.js and user.js files in the Firefox profile and from application defaults. Many of these preferences are advanced settings that are not present in the Options dialog.
The prefs.js file does not actually contain all of the settings. It only stores changes made to the defaults, after they are written back to disk. prefs.js is a plain-text file that can be edited with a text editor. However, its recommended that you don't edit it directly since you can damage your profile if you make any mistakes.
A user.js file is an alternative method of modifying preferences, recommended for advanced users only. Unless you need a user.js file for a specific purpose you should use about:config instead. The user.js file does not exist by default.
Warning: Changing these advanced settings can sometimes break Firefox or cause strange behavior. You should only do this if you know what you're doing or if you are following trustworthy advice.
How:
- Enter "about:config" in the firefox address bar and press enter.
- Press the button "I'll be careful, I promise!"
- Follow the instructions below.
Starting Steps :
- privacy.trackingprotection.enabled = true
This is Mozilla’s new built in tracking protection.
- geo.enabled = false
Disables geolocation.
- browser.safebrowsing.enabled = false
Disable Google Safe Browsing and phishing protection. Security risk, but privacy improvement.
- browser.safebrowsing.malware.enabled = false
Disable Google Safe Browsing malware checks. Security risk, but privacy improvement.
- dom.event.clipboardevents.enabled = false
Disable that websites can get notifications if you copy, paste, or cut something from a web page, and it lets them know which part of the page had been selected.
- network.cookie.cookieBehavior = 1
Disable cookies
0 = accept all cookies by default
1 = only accept from the originating site (block third party cookies)
2 = block all cookies by default
- network.cookie.lifetimePolicy = 2
cookies are deleted at the end of the session
0 = Accept cookies normally
1 = Prompt for each cookie
2 = Accept for current session only
3 = Accept for N days
- browser.cache.offline.enable = false
Disables offline cache.
- browser.send_pings = false
The attribute would be useful for letting websites track visitors’ clicks.
- webgl.disabled = true
WebGL is a potential security risk. Source
- dom.battery.enabled = false
Website owners can track the battery status of your device. Source
- browser.sessionstore.max_tabs_undo = 0
Thursday, January 21, 2016
Calling main() from main() in c/c++
Many people think that when the main() function call inside the main(), recursion goes on infinite times. But it is not true as such so is it possible to call main() from main inside.?
Yes, we can call the main() within the main() function. The process of calling a function by the function itself is known as Recursion. Well, you can call a main() within the main() function .
Yes, we can call the main() within the main() function. The process of calling a function by the function itself is known as Recursion. Well, you can call a main() within the main() function .
The function calls take place until the stack overflow occurs, that is until the stack is completely filled with the functions. This implies that the recursion without a suitable condition takes place not infinite times but stack size times.So that particular experiment when conducted, compiles successfully but it suffers from a run time error or illegal instruction. So you should have a condition that does not call the main() function to terminate the program. Otherwise,the program will never return and run infinitely.
In first example global variable c=0 declared (bcz when main() called is should not reintialized) and after print statement first time it will print 1 (c+1)and condition will true so after calling main it will print 1 now condition will false so program will exit.
#include"stdio.h"
#include"conio.h"
int c=0;
void main(){
clrscr();
printf("Before main : %d",c);
c++;
if(c<2){
main();
exit(0);
}
getch();
}
--------------------------------------------------------------------------------------
int main() {
cout << "Hello World" << endl;
system("pause");//for pause program execution
return main();
}
Sunday, September 20, 2015
GOD MODE in windows
How to Use God Mode in Windows 7
Windows 7 is now becoming popular among windows operating system users.Windows 7 has cool hidden feature ,people calls it godmode in windows 7.GodMode is a folder that brings together a long list of customization settings allowing you to change all your settings from one place.This is very good as you can now change all your windows settings from one single place.
Follow the following steps to create god mode folder:
1. Create a new folder
2. Rename the folder to GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}
"You can change name GodMode to any other word you like ANYTHING(i.e.xyz.{ED7BA470-8E54-465E-825C-99712043E01C})"
3.The folder icon will change ,then double click it to show the GodMode windows options.
That Folder Contains Action Center,Network Configurations,Keybaord-Mouse Management,Device,Display,Homegroup,Bitlocker,Gadgets, in short everything.,
Windows 7 is now becoming popular among windows operating system users.Windows 7 has cool hidden feature ,people calls it godmode in windows 7.GodMode is a folder that brings together a long list of customization settings allowing you to change all your settings from one place.This is very good as you can now change all your windows settings from one single place.
Follow the following steps to create god mode folder:
1. Create a new folder
2. Rename the folder to GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}
"You can change name GodMode to any other word you like ANYTHING(i.e.xyz.{ED7BA470-8E54-465E-825C-99712043E01C})"
3.The folder icon will change ,then double click it to show the GodMode windows options.
That Folder Contains Action Center,Network Configurations,Keybaord-Mouse Management,Device,Display,Homegroup,Bitlocker,Gadgets, in short everything.,
Browse Forum Without Logging
Visit any forum or website to find something useful and they will ask you to register.
All websites and forums will block unregistered users, but they won’t block Google Bot(spider). What we will do is to switch our User Agent to that of Google Bot and freely browse any website or forum without registering.
First grab the User Agent Switcher add-on for Firefox called ‘user agent’ and install it.
Now go to Tools > User Agent Switcher > Options and then again to Options.
Select User Agent from the left sidebar and click Add. Now in the description field type:
crawl-66-249-66-1.googlebot.com
and in user agent field type:
Googlebot/2.1 (+http://www.googlebot.com/bot.html)
as shown in the screenshot below.
Select Google Bot as your User Script by going to Tools > User Agent Switcher.
Now you can browse website or forum without registering.
All websites and forums will block unregistered users, but they won’t block Google Bot(spider). What we will do is to switch our User Agent to that of Google Bot and freely browse any website or forum without registering.
First grab the User Agent Switcher add-on for Firefox called ‘user agent’ and install it.
Now go to Tools > User Agent Switcher > Options and then again to Options.
Select User Agent from the left sidebar and click Add. Now in the description field type:
crawl-66-249-66-1.googlebot.com
and in user agent field type:
Googlebot/2.1 (+http://www.googlebot.com/bot.html)
as shown in the screenshot below.
Select Google Bot as your User Script by going to Tools > User Agent Switcher.
Now you can browse website or forum without registering.
Unable to Open COS.OBJ File In C
Linker Error:Unable to open File COS.OBJ
This error is also due to the incorrect path of Library Directories. Default path for library is “C:/TC/LIB”. But if you are not installed Turbo C on another location or if you moved the installed TC folder to another, then you have two choices to correct the path. One is move your installed TC folder to you C drive without making a new folder. or change the path of library directory to path of your (installed) library folder (Example: D:/Software/Turbo C/ TC/LIB). Be ensure the LIB folder contains all library files like ‘COS.OBJ’, ‘COT.OBJ’ etc.For set path Follow Steps:
1.Open Turbo c.
2.GoTo Options.
3.Click on Directeries.
In Library Directories set the Default path'C:/TC/LIB' or your location(may be not same in all pc, so first you need to check) where LIB folder is located.
Remove Write Protection Of USB Drive
1.Using CMD
when your USB drive plugged in, launch a command prompt. By searching cmd.exe in the Start menu .You may need to run Cmd.exe with administrator privileges if you see an “access is denied” message.
In CMD follow This Commands:
diskpart
list disk
>select disk n (n is the number of your USB drive)
attributes disk clear readonly
clean
create partition primary
format fs=fat32 (you can swap fat32 for ntfs if use the drive with Windows)
exit
2.Using Registry
>run Regedit.exe
Navigate to the following key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies
Double-click on the WriteProtect value in the right-hand pane of Regedit.exe. Change the Value data from 1 to 0 and click OK to save the change. Close Regedit and restart your computer. Connect your USB drive again, and you should find it is no longer write protected. If you can’t find StorageDevicePolicies, you can try creating a key by right-clicking in the white space in the Control folder and choosing New -> Key and carefully entering the name.Now double-click on the new key (folder) and right-click once again and choose New -> DWORD. Name it WriteProtect and set its value to 0. Click OK, exit Regedit and reboot your computer.
Labels:
cmd
,
registry
,
usb
,
windows
,
write protection
Subscribe to:
Posts
(
Atom
)