Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignment 02 #12

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Prerequisites
*.d

# Object files
*.o
*.ko
*.obj
*.elf

# Linker output
*.ilk
*.map
*.exp

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

# Debug files
*.dSYM/
*.su
*.idb
*.pdb

# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf

# vscode
.vscode
vscode
.vscode/*
29 changes: 29 additions & 0 deletions assignments/02/README.Md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Problem Statement #
## A _C_ Program that will create a txt file. ##

**The program problem statement :**
1. This will ask how many lines do user want to write.
2. Then this will read lines accordingly.
3. Then it will ask whether to save or not.
4. At last, it will ask for the file name to save.


### Example
```text
$ ./a.out
How many line do you want to write ?
> 3 (eg. 3)
Alright start writting...

1| I'm Suman.
2| And this is a C project.
3| But my favorite language is Rust.

Do you want to save it ? (Y/N)
> Y (eg. Y & Y is by )

Please gave A file name.
> abcd (eg. abcd)

// This will save a file named `abcd.txt`
```
40 changes: 40 additions & 0 deletions assignments/02/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include <stdio.h>
#include <string.h>

int main()
{
int lines = 0;
char text[lines][1024], fileName[25];
char YN;

printf("How many lines do you want to write ?\n> ");
scanf("%d", &lines);

if (lines)
{
char temp[256];
for (int i = 0; i < lines; i++)
{
printf("%d | ", i + 1);
scanf("%s", temp);
strcpy(text[i], temp);
}
}
else
{
printf("No lines to write\n");
}

printf("Do you want to save it ?(Y/N)\n> ");
scanf("%s", &YN);

if (YN == 'N' || YN == 'n')
{
printf("s");
}

return 0;
}

// unable to coplete need help!
// unable to get line from cli