Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: rafiks/my-sandbox
base: a687fe724e
...
head fork: rafiks/my-sandbox
compare: 92c1335d90
Checking mergeability… Don't worry, you can still create the pull request.
  • 4 commits
  • 23 files changed
  • 0 commit comments
  • 1 contributor
View
3  -.s
@@ -0,0 +1,3 @@
+ .file "-"
+
+ .section ".note.GNU-stack","",@progbits
View
26 array.c
@@ -0,0 +1,26 @@
+#include <stdio.h>
+
+int main(int argc, const char *argv[])
+{
+ int c, i, nwhite, nother;
+ int ndigit[10];
+
+ nwhite = nother = 0;
+ for (i = 0; i < 10; i++) {
+ ndigit[i] = 0
+ }
+ while ((c = getchar() != EOF) {
+ if (c >= '0' && c <= '9') {
+ ++ndigit[c-'0'];
+ }
+ else if (c == ' ' || c == '\n' || c == '\t') {
+ ++nwhite;
+ }
+ ++nother;
+ }
+ printf("digits =");
+ for (i = 0; i < 10; i++) {
+ /* code */
+ }
+ return 0;
+}
View
BIN  buildstr1
Binary file not shown
View
BIN  copychar
Binary file not shown
View
16 copychar.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+
+/* count characters in input ; 1st versin*/
+
+int main(int argc, const char *argv[])
+{
+ long nc;
+
+ nc = 0;
+
+ while (getchar() != EOF) {
+ ++nc;
+ }
+ printf("%ld\n", nc);
+ return 0;
+}
View
BIN  core
Binary file not shown
View
BIN  digit
Binary file not shown
View
28 digit.c
@@ -0,0 +1,28 @@
+#include <stdio.h>
+
+int main(int argc, const char *argv[])
+{
+ int c, i, nwhite, nother;
+ int ndigit[10];
+
+ nwhite = nother = 0;
+ for (i = 0; i < 10; ++i) {
+ ndigit[i] = 0;
+ }
+ while ((c = getchar()) != EOF) {
+ if (c >= '0' && c <= '9') {
+ ++ndigit[c-'0'];
+ }
+ else if (c == ' ' || c == '\n' || c == '\t') {
+ ++nwhite;
+ }
+ else
+ ++nother;
+ }
+ printf("digits =");
+ for (i = 0; i < 10; ++i) {
+ printf("%d", ndigit[i]);
+ }
+ printf(", white space = %d, other = %d\n", nwhite, nother);
+ return 0;
+}
View
BIN  editor
Binary file not shown
View
34 editor.cpp
@@ -0,0 +1,34 @@
+#include <iostream>
+#include <fstream>
+#include <string.h>
+using namespace std;
+
+int main(int argc, char const *argv[])
+{
+ char filename[81];
+ char input_line[81];
+
+ cout << "filename: ";
+ cin.getline(filename, 80);
+
+ ofstream file_out(filename);
+
+ if (! file_out)
+ {
+ cout << "File " << filename << "could not be opened.";
+ return -1;
+ }
+
+ cout << "File " << filename << "was opened." << endl;
+ while(1){
+ cout << "@@@ to exit: ";
+ cin.getline(input_line, 80);
+ if (strcmp(input_line, "@@@")== 0)
+ {
+ break;
+ }
+ file_out << input_line << endl;
+ }
+ file_out.close();
+ return 0;
+}
View
4 editt.txt
@@ -0,0 +1,4 @@
+jfkafja
+afdafdafjafldkafj
+fajfdkfjda
+fafjasflsa
View
BIN  gcf
Binary file not shown
View
BIN  hello
Binary file not shown
View
64 readmore.cpp
@@ -0,0 +1,64 @@
+#include <iostream>
+#include <cstdlib>
+#include <fstream>
+#include <string.h>
+using namespace std;
+
+
+void convert_to_upper(char *s);
+
+int main()
+{
+ int c;
+ int i;
+
+ char filename[81];
+ char input_line[81];
+
+ cout << "Enter a filename and press Enter: ";
+ cin.getline(filename,80);
+
+ ifstream file_in(filename);
+
+ if (!file_in)
+ {
+ cout << "FIle " << filename;
+ cout << "could not be opened.";
+ return -1;
+ }
+
+ int lines_to_read = 20; //default 20
+ while (1){
+ for (i = 1; i <= lines_to_read && ! file_in.eof(); ++i)
+ {
+ file_in.getline(input_line,80);
+ convert_to_upper(input_line);
+ cout << input_line << endl;
+ }
+ if (file_in.eof())
+ {
+ break;
+ }
+ cout << "More? (Press 'Q' and Enter to quit.)";
+ cin.getline(input_line,80);
+ c = input_line[0];
+ if (c == 'Q' || c == 'q')
+ {
+ break;
+ }
+ else if (strlen(input_line) > 0)
+ {
+ lines_to_read = atoi(input_line);
+ }
+ }
+
+ return 0;
+}
+
+void convert_to_upper(char *s) {
+ int i;
+ int length = strlen(s);
+
+ for (i = 0; i < length; i++)
+ s[i] = toupper(s[i]);
+}
View
BIN  readtxt
Binary file not shown
View
49 readtxt.cpp
@@ -0,0 +1,49 @@
+#include <iostream>
+#include <fstream>
+using namespace std;
+
+int main()
+{
+ int c;
+ int i;
+
+ char filename[81];
+ char input_line[81];
+
+ cout << "Enter a filename and press Enter: ";
+ cin.getline(filename,80);
+
+ ifstream file_in(filename);
+
+ if (!file_in)
+ {
+ cout << "FIle " << filename;
+ cout << "could not be opened.";
+ return -1;
+ }
+
+ while (1){
+ int line = 0;
+ for (i = 1; i <= line && ! file_in.eof(); ++i)
+ {
+ file_in.getline(input_line,80);
+ cout << input_line << endl;
+ }
+ if (file_in.eof())
+ {
+ break;
+ }
+ cout << "More? (Press 'Q' and Enter to quit.)";
+ cin.getline(input_line,80);
+ c = input_line[0];
+ if (c == 'Q' || c == 'q')
+ {
+ break;
+ }
+ if (line = atoi(c))
+ {
+ /* code */
+ }
+ }
+ return 0;
+}
View
12 tabcompletetest.cpp
@@ -0,0 +1,12 @@
+#include "tabcompletetest.h"
+#include <iostream>
+using namespace std;
+
+int test;
+
+int main(int argc, char const *argv[])
+{
+ int test;
+ wh
+ return 0;
+}
View
BIN  test.bin
Binary file not shown
View
BIN  word
Binary file not shown
View
27 wordc.c
@@ -0,0 +1,27 @@
+#include <stdio.h>
+
+#define IN 1
+#define OUT 0
+
+int main(int argc, const char *argv[])
+{
+ int c, nl, nw, nc, state;
+
+ state = OUT;
+ nl = nw = nc = 0;
+ while ((c = getchar()) != EOF) {
+ ++nc;
+ if (c == '\n') {
+ ++nl;
+ }
+ if (c == ' ' || c == '\n' || c == '\t') {
+ state = OUT;
+ }
+ else if (state == OUT) {
+ state == IN;
+ ++nw;
+ }
+ }
+ printf("%d %d %d\n", nl, nw, nc);
+ return 0;
+}
View
BIN  writebin
Binary file not shown
View
54 writebin.cpp
@@ -0,0 +1,54 @@
+#include <iostream>
+#include <fstream>
+#include <cstdlib>
+#include "string.h"
+using namespace std;
+
+int get_int(int default_value);
+char name[20];
+
+int main(int argc, char const *argv[])
+{
+ char filename[81];
+ int n;
+ int age;
+ int recsize = sizeof(name) + sizeof(int);
+
+ cout << "Enter file name: ";
+ cin.getline(filename, 80);
+
+ fstream fbin(filename, ios::binary | ios::in | ios::out);
+ if (!fbin)
+ {
+ cout << "Could not open file " << filename;
+ return -1;
+ }
+ //Get record tnumber to write
+ cout << "Enter file record number: ";
+ n = get_int(0);
+
+ //get data from end user
+ cout << "Enter name: ";
+ cin.getline(name, 19);
+ cout << "Enter age: ";
+ age = get_int(0);
+
+ //write data
+ fbin.seekp(n * recsize);
+ fbin.write(name, 20);
+ fbin.write(reinterpret_cast<char*>(&age), sizeof(int));
+ fbin.close();
+
+ return 0;
+}
+
+int get_int(int default_value){
+ char s[81];
+
+ cin.getline(s, 80);
+ if (strlen(s) == 0)
+ {
+ return default_value;
+ }
+ return atoi(s);
+}
View
54 writebin2.cpp
@@ -0,0 +1,54 @@
+#include <iostream>
+#include <fstream>
+#include <cstdlib>
+#include "string.h"
+using namespace std;
+
+int get_int(int default_value);
+char name[20];
+
+int main(int argc, char const *argv[])
+{
+ char filename[81];
+ int n;
+ int age;
+ int recsize = sizeof(name) + sizeof(int);
+
+ cout << "Enter file name: ";
+ cin.getline(filename, 80);
+
+ fstream fbin(filename, ios::binary | ios::in | ios::out);
+ if (!fbin)
+ {
+ cout << "Could not open file " << filename;
+ return -1;
+ }
+ //Get record tnumber to write
+ cout << "Enter file record number: ";
+ n = get_int(0);
+
+ //get data from end user
+ cout << "Enter name: ";
+ cin.getline(name, 19);
+ cout << "Enter age: ";
+ age = get_int(0);
+
+ //write data
+ fbin.seekp(n * recsize);
+ fbin.write(name, 20);
+ fbin.write(reinterpret_cast<char*>(&age), sizeof(int));
+ fbin.close();
+
+ return 0;
+}
+
+int get_int(int default_value){
+ char s[81];
+
+ cin.getline(s, 80);
+ if (strlen(s) == 0)
+ {
+ return default_value;
+ }
+ return atoi(s);
+}

No commit comments for this range

Something went wrong with that request. Please try again.