How to write a C programming proposal?

In summary, the interface will consist of a set of functions and data structures that will be used by the program. The user will be able to input data and get output back. There are routines for getting information about the file system.
  • #1
yukari1310
16
0
I'm new at C programming. My course required me to write a proposal with the title "Word Processing'. It sounds: Create an interface that emulates basic word processing. Ask the
user to input text and save it to "txt" format. The user should be
able to modify, add and remove any of the sentences. You can
limit the sentence length.- My problem here is developing an algorithm.
 
Technology news on Phys.org
  • #2
yukari1310 said:
I'm new at C programming. My course required me to write a proposal with the title "Word Processing'. It sounds: Create an interface that emulates basic word processing. Ask the
user to input text and save it to "txt" format. The user should be
able to modify, add and remove any of the sentences. You can
limit the sentence length.- My problem here is developing an algorithm.

Hey yukari1310 and welcome to the forums.

The first thing you will need to do is to develop an interface.

The interface is basically going to consist of a bunch of functions and data structures that you will use for your project. You will have to think of all the data that passes to and from the function and declare everything that is going to publically available to the program as well as all your data structures that are in the interface functions.

You will have to know what you are doing to create this interface and even before you write code. The structures and the interface will relate to what you actually need to do.

Some advice for you is to think about what the data is, how you want to modify or filter it and what specific functionality you need to implement and how that affects the data in the data structures.
 
  • #3
I need the solution asap cause i have to submit the proposal by this friday... can anyone out there help me?
 
  • #4
yukari1310 said:
I need the solution asap cause i have to submit the proposal by this friday... can anyone out there help me?

We don't do work for people, but following on from what I said above translate the requirements into functions and data and then write them out using structs and functions and that will be your interface.
 
  • #5
Do you need to write the code or just the proposal about the code? It appears that this word processor operates on a group of sentences. Once data is entered (or read from a file), it's not clear how the user will specify which sentence to change. Removing and inserting sentences will not be difficult, but "modifying" sentences could mean that you'd have to create an user interface that allows a user to insert, replace, or delete characters in a sentence. This user interface would be system specific (unix, dos console window, windows text box, ...).
 
  • #6
Yes. It is the code that i need. What's the different between removing/inserting and modifying? they sound the same to me
 
  • #7
yukari1310 said:
Yes. It is the code that i need. What's the different between removing/inserting and modifying? they sound the same to me

An interface is not the same as the actual code: it is only the implementation details for an external user to 'do stuff'.

This is a common thing in software development. What usually happens is that you need to do something that you don't have time for, or the expertise to do so you get someone else to write stuff that allows them to do what you need to without knowing how it actually works (but you know what it will do for your needs).

This is what an interface is: it's basically a published set of all the routines and data structure definitions that the functions use. It contains no code: only these things.

Then what you do is you supply all the data and arguments for the routines and it will spit back the results plus say if an error occured.

You will need to know this like the back of your hand if you ever do software development for a living, because this is what goes on all the time.

Again you don't need to supply the code (yet) to actually do all the stuff but you need to think of the functions and the data structures that will available to the outside coder so that they can do what you've been asked to help them do.

If you are having trouble with understanding this think of header files (.h) vs the code (.c, .cpp). This will make things a lot easier if you understand this kind of thing.
 
  • #8
Can you show me an example of interface?
 
  • #9
yukari1310 said:
Can you show me an example of interface?

Here is a really simple one for a file system:

Code:
// Sample interface for file I/O. Assume strings are ANSI 8-bit null terminated

// File handle 
typedef int FHANDLE;

// File system routine status
typedef int FSTATUS;

// Haven't used C in a while so if const keyword is supported then use it

FSTATUS OpenFile(FHANDLE* fileHandle, char* filePath, unsigned int flags);
FSTATUS CloseFile(FHANDLE fileHandle);
FSTATUS ReadFile(FHANDLE fileHandle, char* arrayForReading, unsigned int sizeToRead, unsigned int* numberOfBytesRead);
FSTATUS GetFilePointer(FHANDLE fileHandle, unsigned int* currentPointer)
FSTATUS SetFilePointer(FHANDLE fileHandle, unsigned int newPointer);
FSTATUS WriteFile(FHANDLE fileHandle, char* arrayForWriting, unsigned int bytesToWrite, unsigned int* bytesWritten);

You then take this interface and implement the actual code somewhere else.
 
  • #10
yukari1310 said:
Yes. It is the code that i need. What's the different between removing/inserting and modifying? they sound the same to me
Removing or inserting sentences, just requires the ability to allow the user to specify a sentence to delete and being able to enter a new sentence to insert.

Modifying a sentence requires a user interface that allows the user to move a cursor back and forth, and modify, insert, or delete characters, while maintaining the current display of that sentence on the user's screen as well as in the program's memory. I find it difficult to believe that this is what the instructor intends for you to implement.

If this is allowed, you could implement a "modify" that just deletes a sentence and requires the user to enter a new sentance to replace the one that was deleted. You should find out from your instructor if this is acceptable.
 
  • #11
modifying was indeed too difficult for amateur like me. i am exposed to C just 11 weeks ago. anyway thanks for the help you both gave. it is really helpful
 
  • #12
one last question. how to add a word into a string and how to remove a word from a string? ps: not replacing word
 
  • #13
yukari1310 said:
one last question. how to add a word into a string and how to remove a word from a string? ps: not replacing word

The short answer is to allocate memory big enough for the two strings (string1size + string2size + 1 for null terminator character assuming ANSI 8-bit string), and then copy the contents from string1 into array then string2 into array and then set last byte to 0x00.

If you are adding a word in-between then do the same thing as above but instead of two strings you will have three strings and you add them all together. If you are removing something from a string, again do the same thing: allocate memory for a new string, copy of the contents that don't include the stuff you are removing (string1 = string before stuff being removed, string2 = string after stuff being removed) and then put the null terminator at the end.

Also remember to clean up any memory that needs to be deallocated and check for errors throughout the entire process and clean up any loose ends accordingly. Also make sure that the memory is allocated correctly: (check if pointer is non-zero).
 
  • #14
I have started to code in Pascal then C since I was 18, and changed myself abruptly into C++ because C made me suffer a lot; its constructs always induce leaks. That means it is wet and therefore easily contaminated with security holes and viruses. For your references, you can resolve your current problem with a linked-list in which you can store your words as nodes; Therefore, adding and removing a node also means adding and removing a word.
Code:
struct WORD
{
   char myword[999];
   WORD*newWord;
   //etc
};
 
  • #15
okay... how should i initialize each string[] as the text can be randomly input by the user?
 
  • #16
yukari1310 said:
one last question. how to add a word into a string and how to remove a word from a string? ps: not replacing word
You could split up the process into one where you use 2 or 3 strings as mentioned by chiro, or you could directly insert or remove words from an existing string by shifting all the characters after the word, downwards if deleting a word or upwards if inserting a word in the array. If shifting upwards (inserting), you would have to start at what will be the end of the updated string to avoid overwriting existing characters. In both cases, you move one character at a time.

phylotree said:
For your references, you can resolve your current problem with a linked-list in which you can store your words as nodes.

yukari1310 said:
okay... how should i initialize each string[] as the text can be randomly input by the user?
I'm not sure this buys you much. With a linked list, you have to parse the original input sentence string into a linked list of words, and you have to traverse the linked list to create a sentence string for output. It does make inserting and deleting words easier. If you want to try this, you just initialize each string to a nulll string. Also it would make more sense for the name of the node pointer in the word structure to be "nextWord", instead of "newWord".
 
  • #17
what's the code for this? anyone?: add spaces between words in spaceless C string
 
  • #18
yukari1310 said:
what's the code for this? anyone?: add spaces between words in spaceless C string
As already noted in this thread, we are not here to do your work for you. You've been in the class now for 11 weeks, so you should have some idea how to write C code. Show us what you've done and we can help you with it, but don't expect us to do the work for you.
 
  • #19
phylotree said:
I have started to code in Pascal then C since I was 18, and changed myself abruptly into C++ because C made me suffer a lot; its constructs always induce leaks.
How is C++ different from C in that regard? If you forget to free() a pointer to heap memory in C or you forget to delete memory that you allocated with new, the result is the same - a memory leak.
phylotree said:
That means it is wet
wet - ?
phylotree said:
and therefore easily contaminated with security holes and viruses.
Memory leaks are not security holes, and are not an avenue for viruses.
phylotree said:
For your references, you can resolve your current problem with a linked-list in which you can store your words as nodes; Therefore, adding and removing a node also means adding and removing a word.
Code:
struct WORD
{
   char myword[999];
   WORD*newWord;
   //etc
};
 

1. What is the purpose of a C programming proposal?

A C programming proposal outlines the objectives, methods, and potential outcomes of a proposed project involving the use of the C programming language. It serves as a roadmap for the project and helps stakeholders understand the scope and significance of the proposed work.

2. What should be included in a C programming proposal?

A C programming proposal should include a clear title, a brief summary of the project, the objectives and goals, the methodology and approach, a timeline, and a budget. It should also include information on the project team, their qualifications, and any resources or equipment needed for the project.

3. How long should a C programming proposal be?

The length of a C programming proposal can vary depending on the complexity of the project. However, it is recommended to keep it concise and to the point, typically ranging from 3-5 pages. It should provide enough detail to give a clear understanding of the project without overwhelming the reader with unnecessary information.

4. Who should I target with my C programming proposal?

A C programming proposal should be targeted towards stakeholders and decision-makers who have a vested interest in the project. This may include project sponsors, investors, potential clients, or other members of the scientific community who may be interested in the proposed work.

5. What makes a C programming proposal successful?

A successful C programming proposal should clearly communicate the significance and potential impact of the proposed project. It should also demonstrate a strong understanding of the C programming language and its capabilities, as well as a well-defined methodology and timeline for the project. Additionally, a realistic and detailed budget and a qualified project team can also contribute to the success of a C programming proposal.

Similar threads

  • Programming and Computer Science
Replies
22
Views
921
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
2
Replies
69
Views
4K
  • Programming and Computer Science
Replies
25
Views
2K
  • Programming and Computer Science
Replies
14
Views
31K
  • Programming and Computer Science
3
Replies
81
Views
5K
  • Programming and Computer Science
Replies
4
Views
3K
Replies
6
Views
1K
  • Programming and Computer Science
Replies
6
Views
2K
  • Sticky
  • Programming and Computer Science
Replies
13
Views
4K
Back
Top