Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I am working with windows platform, i want to run notepad file with the help of C program. What i tried is here
#include<stdio.h>
#include<conio.h>
#include<process.h>
void main()
{
clrscr();
   system("C:\\windows\\notepad.exe");
   getch();
}



The code has no errors but still am not able to see a new notepad file. Please help me out

Thanks & regards
Radix :rose:
Posted
Updated 2-Dec-19 3:14am

A simple executable like:

#include <stdlib>

int main()
{
    system( "notepad" );
}


works for me on VC++2005 and XP. If you open a command prompt as the same user you're running your C program as can you invoke notepad just by typing "notepad"?

Cheers,

Ash
 
Share this answer
 
Comments
Nish Nishant 16-Jul-10 11:22am    
Reason for my vote of 5
Worth 5. Not sure why someone 4d this.
radix3 19-Jul-10 10:14am    
I am using Turbo C and i tried the above code it's not working. I even wrote the full path of notepad but alas no success
I thought that ShellExecute was a C API, and not a C++ one.
 
Share this answer
 
Comments
radix3 16-Jul-10 8:17am    
Sir i didn't get you.can you please explain
I tried your code on my PC and it works properly. You specified the full-path of notepad: are you sure that it is correct?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900